Commit 389c5db0 authored by Frédéric Caplette's avatar Frédéric Caplette

Replace calls to writeQuery for client mutations in PA

Instead of writing directly to cache with writeQuery call to
apollo, we use a local mutation and resolver. There
are no user facing changes.
parent 5e38e52a
......@@ -10,8 +10,8 @@ import {
import commitCIFile from '../../graphql/mutations/commit_ci_file.mutation.graphql';
import updateCurrentBranchMutation from '../../graphql/mutations/update_current_branch.mutation.graphql';
import updateLastCommitBranchMutation from '../../graphql/mutations/update_last_commit_branch.mutation.graphql';
import updatePipelineEtag from '../../graphql/mutations/update_pipeline_etag.mutation.graphql';
import getCurrentBranch from '../../graphql/queries/client/current_branch.graphql';
import getPipelineEtag from '../../graphql/queries/client/pipeline_etag.graphql';
import CommitForm from './commit_form.vue';
......@@ -96,10 +96,10 @@ export default {
content: this.ciFileContent,
lastCommitId: this.commitSha,
},
update(store, { data }) {
update(_, { data }) {
const pipelineEtag = data?.commitCreate?.commit?.commitPipelinePath;
if (pipelineEtag) {
store.writeQuery({ query: getPipelineEtag, data: { pipelineEtag } });
this.$apollo.mutate({ mutation: updatePipelineEtag, variables: pipelineEtag });
}
},
});
......
mutation updatePipelineEtag($pipelineEtag: String) {
updatePipelineEtag(pipelineEtag: $pipelineEtag) @client
}
......@@ -2,6 +2,7 @@ import axios from '~/lib/utils/axios_utils';
import getAppStatus from './queries/client/app_status.graphql';
import getCurrentBranchQuery from './queries/client/current_branch.graphql';
import getLastCommitBranchQuery from './queries/client/last_commit_branch.query.graphql';
import getPipelineEtag from './queries/client/pipeline_etag.graphql';
export const resolvers = {
Mutation: {
......@@ -49,5 +50,11 @@ export const resolvers = {
data: { lastCommitBranch },
});
},
updatePipelineEtag: (_, { pipelineEtag }, { cache }) => {
cache.writeQuery({
query: getPipelineEtag,
data: { pipelineEtag },
});
},
},
};
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