2021-06-08 01:23:25 +05:30
|
|
|
import { IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
|
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';
|
2021-09-04 01:27:46 +05:30
|
|
|
import getIssueStateQuery from '~/issue_show/queries/get_issue_state.query.graphql';
|
2021-04-17 20:07:23 +05:30
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2021-06-08 01:23:25 +05:30
|
|
|
import introspectionQueryResultData from './fragmentTypes.json';
|
2021-04-17 20:07:23 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
const fragmentMatcher = new IntrospectionFragmentMatcher({
|
|
|
|
introspectionQueryResultData,
|
|
|
|
});
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
const resolvers = {
|
|
|
|
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
|
|
|
},
|
|
|
|
},
|
2021-09-04 01:27:46 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
export const defaultClient = createDefaultClient(resolvers, {
|
|
|
|
cacheConfig: {
|
|
|
|
fragmentMatcher,
|
|
|
|
},
|
|
|
|
});
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
export const apolloProvider = new VueApollo({
|
|
|
|
defaultClient,
|
|
|
|
});
|