Commit 351d1321 authored by Marius Bobin's avatar Marius Bobin

Use ETag header received from backend

parent a7dac970
...@@ -23,6 +23,9 @@ export default { ...@@ -23,6 +23,9 @@ export default {
pipelineProjectPath: { pipelineProjectPath: {
default: '', default: '',
}, },
graphqlResourceEtag: {
default: '',
},
}, },
data() { data() {
return { return {
...@@ -45,7 +48,7 @@ export default { ...@@ -45,7 +48,7 @@ export default {
}, },
headers: { headers: {
'X-GITLAB-GRAPHQL-FEATURE-CORRELATION': 'verify/ci/pipeline-graph', 'X-GITLAB-GRAPHQL-FEATURE-CORRELATION': 'verify/ci/pipeline-graph',
'X-GITLAB-GRAPHQL-RESOURCE-ETAG': `pipelines/id/${this.pipelineIid}`, 'X-GITLAB-GRAPHQL-RESOURCE-ETAG': this.graphqlResourceEtag,
'X-REQUESTED_WITH': 'XMLHttpRequest', 'X-REQUESTED_WITH': 'XMLHttpRequest',
}, },
}; };
......
...@@ -72,14 +72,17 @@ export default { ...@@ -72,14 +72,17 @@ export default {
this.$apollo.addSmartQuery('currentPipeline', { this.$apollo.addSmartQuery('currentPipeline', {
query: getPipelineDetails, query: getPipelineDetails,
pollInterval: 10000, pollInterval: 10000,
context: { context() {
fetchOptions: { return {
method: 'GET', fetchOptions: {
}, method: 'GET',
headers: { },
'X-GITLAB-GRAPHQL-FEATURE-CORRELATION': 'verify/ci/pipeline-graph', headers: {
'X-GITLAB-GRAPHQL-RESOURCE-ETAG': 'pipelines/id/123', 'X-GITLAB-GRAPHQL-FEATURE-CORRELATION': 'verify/ci/pipeline-graph',
}, 'X-GITLAB-GRAPHQL-RESOURCE-ETAG': this.graphqlResourceEtag,
'X-REQUESTED_WITH': 'XMLHttpRequest',
},
}
}, },
variables() { variables() {
return { return {
......
...@@ -99,6 +99,7 @@ export default async function initPipelineDetailsBundle() { ...@@ -99,6 +99,7 @@ export default async function initPipelineDetailsBundle() {
pipelineProjectPath, pipelineProjectPath,
pipelineIid, pipelineIid,
metricsPath, metricsPath,
graphqlResourceEtag,
); );
} catch { } catch {
Flash(__('An error occurred while loading the pipeline.')); Flash(__('An error occurred while loading the pipeline.'));
......
...@@ -16,7 +16,7 @@ const apolloProvider = new VueApollo({ ...@@ -16,7 +16,7 @@ const apolloProvider = new VueApollo({
), ),
}); });
const createPipelinesDetailApp = (selector, pipelineProjectPath, pipelineIid, metricsPath) => { const createPipelinesDetailApp = (selector, pipelineProjectPath, pipelineIid, metricsPath, graphqlResourceEtag) => {
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: selector, el: selector,
...@@ -28,6 +28,7 @@ const createPipelinesDetailApp = (selector, pipelineProjectPath, pipelineIid, me ...@@ -28,6 +28,7 @@ const createPipelinesDetailApp = (selector, pipelineProjectPath, pipelineIid, me
metricsPath, metricsPath,
pipelineProjectPath, pipelineProjectPath,
pipelineIid, pipelineIid,
graphqlResourceEtag,
dataMethod: GRAPHQL, dataMethod: GRAPHQL,
}, },
errorCaptured(err, _vm, info) { errorCaptured(err, _vm, info) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment