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';
Vue.use(VueApollo);
const defaultClient = createDefaultClient();
const defaultClient = createDefaultClient({}, { assumeImmutableResults: true });
const apolloProvider = new VueApollo({
defaultClient,
......
......@@ -2,7 +2,6 @@
mutation($input: JiraImportStartInput!) {
jiraImportStart(input: $input) {
clientMutationId
jiraImport {
...JiraImport
}
......
import produce from 'immer';
import getJiraImportDetailsQuery from '../queries/get_jira_import_details.query.graphql';
import { IMPORT_STATE } from './jira_import_utils';
......@@ -13,22 +14,16 @@ export const addInProgressImportToStore = (store, jiraImportStart, fullPath) =>
},
};
const cacheData = store.readQuery({
const sourceData = store.readQuery({
...queryDetails,
});
store.writeQuery({
...queryDetails,
data: {
project: {
...cacheData.project,
jiraImportStatus: IMPORT_STATE.SCHEDULED,
jiraImports: {
...cacheData.project.jiraImports,
nodes: cacheData.project.jiraImports.nodes.concat(jiraImportStart.jiraImport),
},
},
},
data: produce(sourceData, draftData => {
draftData.project.jiraImportStatus = IMPORT_STATE.SCHEDULED; // eslint-disable-line no-param-reassign
draftData.project.jiraImports.nodes.push(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