debian-mirror-gitlab/app/assets/javascripts/sidebar/graphql.js

26 lines
861 B
JavaScript
Raw Normal View History

2021-09-04 01:27:46 +05:30
import produce from 'immer';
2021-04-17 20:07:23 +05:30
import VueApollo from 'vue-apollo';
2022-01-26 12:08:38 +05:30
import getIssueStateQuery from '~/issues/show/queries/get_issue_state.query.graphql';
2022-04-04 11:22:00 +05:30
import { resolvers as workItemResolvers } from '~/work_items/graphql/resolvers';
2021-04-17 20:07:23 +05:30
import createDefaultClient from '~/lib/graphql';
2021-06-08 01:23:25 +05:30
2021-09-04 01:27:46 +05:30
const resolvers = {
2022-04-04 11:22:00 +05:30
...workItemResolvers,
2021-09-04 01:27:46 +05:30
Mutation: {
updateIssueState: (_, { issueType = undefined, isDirty = false }, { cache }) => {
const sourceData = cache.readQuery({ query: getIssueStateQuery });
const data = produce(sourceData, (draftData) => {
draftData.issueState = { issueType, isDirty };
});
cache.writeQuery({ query: getIssueStateQuery, data });
2021-06-08 01:23:25 +05:30
},
2022-04-04 11:22:00 +05:30
...workItemResolvers.Mutation,
2021-06-08 01:23:25 +05:30
},
2021-09-04 01:27:46 +05:30
};
2022-04-04 11:22:00 +05:30
export const defaultClient = createDefaultClient(resolvers);
2021-04-17 20:07:23 +05:30
export const apolloProvider = new VueApollo({
defaultClient,
});