Commit fedc70aa authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'nmezzopera-dast-profiles-immer' into 'master'

Refactor dast profile cache_utils removeProfile to immer

See merge request gitlab-org/gitlab!47298
parents 8effea97 7a8ae2d4
import { produce } from 'immer';
/**
* Appends paginated results to existing ones
* - to be used with $apollo.queries.x.fetchMore
......@@ -24,10 +25,15 @@ export const appendToPreviousResult = profileType => (previousResult, { fetchMor
* @param 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 }) => {
return node.id !== profileId;
const data = produce(sourceData, draftState => {
// 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 });
......
......@@ -5,5 +5,10 @@ import createDefaultClient from '~/lib/graphql';
Vue.use(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