Commit 1290ce53 authored by Coung Ngo's avatar Coung Ngo

Update Jira importer apollo client cache to be immutable

This is done in preparation for upgrading to Apollo Client 3 which
requires immutable cache updates.
parent 797a2c2a
...@@ -6,7 +6,7 @@ import App from './components/jira_import_app.vue'; ...@@ -6,7 +6,7 @@ import App from './components/jira_import_app.vue';
Vue.use(VueApollo); Vue.use(VueApollo);
const defaultClient = createDefaultClient(); const defaultClient = createDefaultClient({}, { assumeImmutableResults: true });
const apolloProvider = new VueApollo({ const apolloProvider = new VueApollo({
defaultClient, defaultClient,
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
mutation($input: JiraImportStartInput!) { mutation($input: JiraImportStartInput!) {
jiraImportStart(input: $input) { jiraImportStart(input: $input) {
clientMutationId
jiraImport { jiraImport {
...JiraImport ...JiraImport
} }
......
import produce from 'immer';
import getJiraImportDetailsQuery from '../queries/get_jira_import_details.query.graphql'; import getJiraImportDetailsQuery from '../queries/get_jira_import_details.query.graphql';
import { IMPORT_STATE } from './jira_import_utils'; import { IMPORT_STATE } from './jira_import_utils';
...@@ -13,22 +14,16 @@ export const addInProgressImportToStore = (store, jiraImportStart, fullPath) => ...@@ -13,22 +14,16 @@ export const addInProgressImportToStore = (store, jiraImportStart, fullPath) =>
}, },
}; };
const cacheData = store.readQuery({ const sourceData = store.readQuery({
...queryDetails, ...queryDetails,
}); });
store.writeQuery({ store.writeQuery({
...queryDetails, ...queryDetails,
data: { data: produce(sourceData, draftData => {
project: { draftData.project.jiraImportStatus = IMPORT_STATE.SCHEDULED; // eslint-disable-line no-param-reassign
...cacheData.project, draftData.project.jiraImports.nodes.push(jiraImportStart.jiraImport);
jiraImportStatus: IMPORT_STATE.SCHEDULED, }),
jiraImports: {
...cacheData.project.jiraImports,
nodes: cacheData.project.jiraImports.nodes.concat(jiraImportStart.jiraImport),
},
},
},
}); });
}; };
......
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