Commit 83aa6108 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '227382-make-jira-import-apollo-client-cache-update-immutable' into 'master'

Update Jira importer apollo client cache update to be immutable

See merge request gitlab-org/gitlab!43318
parents 8062221a 1290ce53
...@@ -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