Commit 7a8ae2d4 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Jose Ivan Vargas

Refactor dast profile cache_utils removeProfile to immer

parent 9a054c85
import { produce } from 'immer';
/** /**
* Appends paginated results to existing ones * Appends paginated results to existing ones
* - to be used with $apollo.queries.x.fetchMore * - to be used with $apollo.queries.x.fetchMore
...@@ -24,10 +25,15 @@ export const appendToPreviousResult = profileType => (previousResult, { fetchMor ...@@ -24,10 +25,15 @@ export const appendToPreviousResult = profileType => (previousResult, { fetchMor
* @param queryBody * @param queryBody
*/ */
export const removeProfile = ({ profileId, profileType, store, queryBody }) => { export const removeProfile = ({ profileId, profileType, store, queryBody }) => {
const data = store.readQuery(queryBody); const sourceData = store.readQuery(queryBody);
data.project[profileType].edges = data.project[profileType].edges.filter(({ node }) => { const data = produce(sourceData, draftState => {
return node.id !== profileId; // eslint-disable-next-line no-param-reassign
draftState.project[profileType].edges = draftState.project[profileType].edges.filter(
({ node }) => {
return node.id !== profileId;
},
);
}); });
store.writeQuery({ ...queryBody, data }); store.writeQuery({ ...queryBody, data });
......
...@@ -5,5 +5,10 @@ import createDefaultClient from '~/lib/graphql'; ...@@ -5,5 +5,10 @@ import createDefaultClient from '~/lib/graphql';
Vue.use(VueApollo); Vue.use(VueApollo);
export default new VueApollo({ export default new VueApollo({
defaultClient: createDefaultClient(), defaultClient: createDefaultClient(
{},
{
assumeImmutableResults: true,
},
),
}); });
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