Commit 20bdc02e authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '227382-security-dashboard-assume-immutability' into 'master'

Set `assumeImmutableResults` in security dashboard

See merge request gitlab-org/gitlab!42505
parents b39b8929 6f8463e4
<script> <script>
import produce from 'immer';
import { GlAlert, GlButton, GlIntersectionObserver } from '@gitlab/ui'; import { GlAlert, GlButton, GlIntersectionObserver } from '@gitlab/ui';
import VulnerabilityList from './vulnerability_list.vue'; import VulnerabilityList from './vulnerability_list.vue';
import vulnerabilitiesQuery from '../graphql/group_vulnerabilities.graphql'; import vulnerabilitiesQuery from '../graphql/group_vulnerabilities.graphql';
...@@ -72,10 +73,14 @@ export default { ...@@ -72,10 +73,14 @@ export default {
this.$apollo.queries.vulnerabilities.fetchMore({ this.$apollo.queries.vulnerabilities.fetchMore({
variables: { after: this.pageInfo.endCursor }, variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
fetchMoreResult.group.vulnerabilities.nodes.unshift( const results = produce(fetchMoreResult, draftData => {
// eslint-disable-next-line no-param-reassign
draftData.group.vulnerabilities.nodes = [
...previousResult.group.vulnerabilities.nodes, ...previousResult.group.vulnerabilities.nodes,
); ...draftData.group.vulnerabilities.nodes,
return fetchMoreResult; ];
});
return results;
}, },
}); });
} }
......
<script> <script>
import produce from 'immer';
import { GlAlert, GlButton, GlIntersectionObserver, GlLoadingIcon } from '@gitlab/ui'; import { GlAlert, GlButton, GlIntersectionObserver, GlLoadingIcon } from '@gitlab/ui';
import { fetchPolicies } from '~/lib/graphql'; import { fetchPolicies } from '~/lib/graphql';
import VulnerabilityList from './vulnerability_list.vue'; import VulnerabilityList from './vulnerability_list.vue';
...@@ -69,8 +70,14 @@ export default { ...@@ -69,8 +70,14 @@ export default {
this.$apollo.queries.vulnerabilities.fetchMore({ this.$apollo.queries.vulnerabilities.fetchMore({
variables: { after: this.pageInfo.endCursor }, variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
fetchMoreResult.vulnerabilities.nodes.unshift(...previousResult.vulnerabilities.nodes); const results = produce(fetchMoreResult, draftData => {
return fetchMoreResult; // eslint-disable-next-line no-param-reassign
draftData.vulnerabilities.nodes = [
...previousResult.vulnerabilities.nodes,
...draftData.vulnerabilities.nodes,
];
});
return results;
}, },
}); });
} }
......
<script> <script>
import produce from 'immer';
import { GlAlert, GlButton, GlIntersectionObserver } from '@gitlab/ui'; import { GlAlert, GlButton, GlIntersectionObserver } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
...@@ -99,12 +100,14 @@ export default { ...@@ -99,12 +100,14 @@ export default {
this.$apollo.queries.vulnerabilities.fetchMore({ this.$apollo.queries.vulnerabilities.fetchMore({
variables: { after: this.pageInfo.endCursor }, variables: { after: this.pageInfo.endCursor },
updateQuery: (previousResult, { fetchMoreResult }) => { updateQuery: (previousResult, { fetchMoreResult }) => {
const newResult = { ...fetchMoreResult }; const results = produce(fetchMoreResult, draftData => {
previousResult.project.vulnerabilities.nodes.push( // eslint-disable-next-line no-param-reassign
...fetchMoreResult.project.vulnerabilities.nodes, draftData.project.vulnerabilities.nodes = [
); ...previousResult.project.vulnerabilities.nodes,
newResult.project.vulnerabilities.nodes = previousResult.project.vulnerabilities.nodes; ...draftData.project.vulnerabilities.nodes,
return newResult; ];
});
return results;
}, },
}); });
} }
......
...@@ -18,6 +18,7 @@ const defaultClient = createDefaultClient( ...@@ -18,6 +18,7 @@ const defaultClient = createDefaultClient(
cacheConfig: { cacheConfig: {
fragmentMatcher, 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