Commit cfe70265 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '276949-unify-apollo' into 'master'

Pipeline Graph Structural Update: Unify Apollo Providers

See merge request gitlab-org/gitlab!56697
parents 78db5e24 4de5a814
...@@ -8,6 +8,7 @@ import cancelPipelineMutation from '../graphql/mutations/cancel_pipeline.mutatio ...@@ -8,6 +8,7 @@ import cancelPipelineMutation from '../graphql/mutations/cancel_pipeline.mutatio
import deletePipelineMutation from '../graphql/mutations/delete_pipeline.mutation.graphql'; import deletePipelineMutation from '../graphql/mutations/delete_pipeline.mutation.graphql';
import retryPipelineMutation from '../graphql/mutations/retry_pipeline.mutation.graphql'; import retryPipelineMutation from '../graphql/mutations/retry_pipeline.mutation.graphql';
import getPipelineQuery from '../graphql/queries/get_pipeline_header_data.query.graphql'; import getPipelineQuery from '../graphql/queries/get_pipeline_header_data.query.graphql';
import { getQueryHeaders } from './graph/utils';
const DELETE_MODAL_ID = 'pipeline-delete-modal'; const DELETE_MODAL_ID = 'pipeline-delete-modal';
const POLL_INTERVAL = 10000; const POLL_INTERVAL = 10000;
...@@ -34,7 +35,9 @@ export default { ...@@ -34,7 +35,9 @@ export default {
[DEFAULT]: __('An unknown error occurred.'), [DEFAULT]: __('An unknown error occurred.'),
}, },
inject: { inject: {
// Receive `fullProject` and `pipelinesPath` graphqlResourceEtag: {
default: '',
},
paths: { paths: {
default: {}, default: {},
}, },
...@@ -47,6 +50,9 @@ export default { ...@@ -47,6 +50,9 @@ export default {
}, },
apollo: { apollo: {
pipeline: { pipeline: {
context() {
return getQueryHeaders(this.graphqlResourceEtag);
},
query: getPipelineQuery, query: getPipelineQuery,
variables() { variables() {
return { return {
......
...@@ -7,6 +7,7 @@ import { reportToSentry } from './components/graph/utils'; ...@@ -7,6 +7,7 @@ import { reportToSentry } from './components/graph/utils';
import TestReports from './components/test_reports/test_reports.vue'; import TestReports from './components/test_reports/test_reports.vue';
import GraphBundleMixin from './mixins/graph_pipeline_bundle_mixin'; import GraphBundleMixin from './mixins/graph_pipeline_bundle_mixin';
import createDagApp from './pipeline_details_dag'; import createDagApp from './pipeline_details_dag';
import { apolloProvider } from './pipeline_shared_client';
import createTestReportsStore from './stores/test_reports'; import createTestReportsStore from './stores/test_reports';
Vue.use(Translate); Vue.use(Translate);
...@@ -80,7 +81,7 @@ const createTestDetails = () => { ...@@ -80,7 +81,7 @@ const createTestDetails = () => {
export default async function initPipelineDetailsBundle() { export default async function initPipelineDetailsBundle() {
createTestDetails(); createTestDetails();
createDagApp(); createDagApp(apolloProvider);
const canShowNewPipelineDetails = const canShowNewPipelineDetails =
gon.features.graphqlPipelineDetails || gon.features.graphqlPipelineDetailsUsers; gon.features.graphqlPipelineDetails || gon.features.graphqlPipelineDetailsUsers;
...@@ -93,7 +94,7 @@ export default async function initPipelineDetailsBundle() { ...@@ -93,7 +94,7 @@ export default async function initPipelineDetailsBundle() {
/* webpackChunkName: 'createPipelinesDetailApp' */ './pipeline_details_graph' /* webpackChunkName: 'createPipelinesDetailApp' */ './pipeline_details_graph'
); );
createPipelinesDetailApp(SELECTORS.PIPELINE_GRAPH, dataset); createPipelinesDetailApp(SELECTORS.PIPELINE_GRAPH, apolloProvider, dataset);
} catch { } catch {
Flash(__('An error occurred while loading the pipeline.')); Flash(__('An error occurred while loading the pipeline.'));
} }
...@@ -111,7 +112,7 @@ export default async function initPipelineDetailsBundle() { ...@@ -111,7 +112,7 @@ export default async function initPipelineDetailsBundle() {
const { createPipelineHeaderApp } = await import( const { createPipelineHeaderApp } = await import(
/* webpackChunkName: 'createPipelineHeaderApp' */ './pipeline_details_header' /* webpackChunkName: 'createPipelineHeaderApp' */ './pipeline_details_header'
); );
createPipelineHeaderApp(SELECTORS.PIPELINE_HEADER); createPipelineHeaderApp(SELECTORS.PIPELINE_HEADER, apolloProvider, dataset.graphqlResourceEtag);
} catch { } catch {
Flash(__('An error occurred while loading a section of this page.')); Flash(__('An error occurred while loading a section of this page.'));
} }
......
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import Dag from './components/dag/dag.vue'; import Dag from './components/dag/dag.vue';
Vue.use(VueApollo); Vue.use(VueApollo);
const apolloProvider = new VueApollo({ const createDagApp = (apolloProvider) => {
defaultClient: createDefaultClient(),
});
const createDagApp = () => {
const el = document.querySelector('#js-pipeline-dag-vue'); const el = document.querySelector('#js-pipeline-dag-vue');
if (!el) { if (!el) {
......
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import { GRAPHQL } from './components/graph/constants'; import { GRAPHQL } from './components/graph/constants';
import PipelineGraphWrapper from './components/graph/graph_component_wrapper.vue'; import PipelineGraphWrapper from './components/graph/graph_component_wrapper.vue';
import { reportToSentry } from './components/graph/utils'; import { reportToSentry } from './components/graph/utils';
Vue.use(VueApollo); Vue.use(VueApollo);
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(
{},
{
useGet: true,
},
),
});
const createPipelinesDetailApp = ( const createPipelinesDetailApp = (
selector, selector,
apolloProvider,
{ pipelineProjectPath, pipelineIid, metricsPath, graphqlResourceEtag } = {}, { pipelineProjectPath, pipelineIid, metricsPath, graphqlResourceEtag } = {},
) => { ) => {
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
......
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import pipelineHeader from './components/header_component.vue'; import pipelineHeader from './components/header_component.vue';
Vue.use(VueApollo); Vue.use(VueApollo);
const apolloProvider = new VueApollo({ export const createPipelineHeaderApp = (elSelector, apolloProvider, graphqlResourceEtag) => {
defaultClient: createDefaultClient(),
});
export const createPipelineHeaderApp = (elSelector) => {
const el = document.querySelector(elSelector); const el = document.querySelector(elSelector);
if (!el) { if (!el) {
...@@ -27,6 +22,7 @@ export const createPipelineHeaderApp = (elSelector) => { ...@@ -27,6 +22,7 @@ export const createPipelineHeaderApp = (elSelector) => {
provide: { provide: {
paths: { paths: {
fullProject: fullPath, fullProject: fullPath,
graphqlResourceEtag,
pipelinesPath, pipelinesPath,
}, },
pipelineId, pipelineId,
......
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
export const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(
{},
{
useGet: true,
},
),
});
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