Welcome to mirror list, hosted at ThFree Co, Russian Federation.

has_submitted_changes.js « resolvers « graphql « static_site_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 35ecf6d698c66006262dde000c94a80672f731cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { produce } from 'immer';
import query from '../queries/app_data.query.graphql';

const hasSubmittedChangesResolver = (_, { input: { hasSubmittedChanges } }, { cache }) => {
  const oldData = cache.readQuery({ query });

  const data = produce(oldData, (draftState) => {
    // punctually modifying draftState as per immer docs upsets our linters
    return {
      ...draftState,
      appData: {
        __typename: 'AppData',
        ...draftState.appData,
        hasSubmittedChanges,
      },
    };
  });

  cache.writeQuery({
    query,
    data,
  });
};

export default hasSubmittedChangesResolver;