Commit 6f8463e4 authored by Alexander Turinske's avatar Alexander Turinske

Set `assumeImmutableResults` in security dashboard

- update apollo client to `assumeImmutableResults` to increase
  performance
- update `updateQuery` for project/group/instane-level security
  dashboard to be consistent and immutable
parent f91ea8e2
<script>
import produce from 'immer';
import { GlAlert, GlButton, GlIntersectionObserver } from '@gitlab/ui';
import VulnerabilityList from './vulnerability_list.vue';
import vulnerabilitiesQuery from '../graphql/group_vulnerabilities.graphql';
......@@ -66,10 +67,14 @@ export default {
this.$apollo.queries.vulnerabilities.fetchMore({
variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => {
fetchMoreResult.group.vulnerabilities.nodes.unshift(
...previousResult.group.vulnerabilities.nodes,
);
return fetchMoreResult;
const results = produce(fetchMoreResult, draftData => {
// eslint-disable-next-line no-param-reassign
draftData.group.vulnerabilities.nodes = [
...previousResult.group.vulnerabilities.nodes,
...draftData.group.vulnerabilities.nodes,
];
});
return results;
},
});
}
......
<script>
import produce from 'immer';
import { GlAlert, GlButton, GlIntersectionObserver, GlLoadingIcon } from '@gitlab/ui';
import { fetchPolicies } from '~/lib/graphql';
import VulnerabilityList from './vulnerability_list.vue';
......@@ -63,8 +64,14 @@ export default {
this.$apollo.queries.vulnerabilities.fetchMore({
variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => {
fetchMoreResult.vulnerabilities.nodes.unshift(...previousResult.vulnerabilities.nodes);
return fetchMoreResult;
const results = produce(fetchMoreResult, draftData => {
// eslint-disable-next-line no-param-reassign
draftData.vulnerabilities.nodes = [
...previousResult.vulnerabilities.nodes,
...draftData.vulnerabilities.nodes,
];
});
return results;
},
});
}
......
<script>
import produce from 'immer';
import { GlAlert, GlButton, GlIntersectionObserver } from '@gitlab/ui';
import { __ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
......@@ -93,12 +94,14 @@ export default {
this.$apollo.queries.vulnerabilities.fetchMore({
variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => {
const newResult = { ...fetchMoreResult };
previousResult.project.vulnerabilities.nodes.push(
...fetchMoreResult.project.vulnerabilities.nodes,
);
newResult.project.vulnerabilities.nodes = previousResult.project.vulnerabilities.nodes;
return newResult;
const results = produce(fetchMoreResult, draftData => {
// eslint-disable-next-line no-param-reassign
draftData.project.vulnerabilities.nodes = [
...previousResult.project.vulnerabilities.nodes,
...draftData.project.vulnerabilities.nodes,
];
});
return results;
},
});
}
......
......@@ -18,6 +18,7 @@ const defaultClient = createDefaultClient(
cacheConfig: {
fragmentMatcher,
},
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