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

resolvers.js « graphql « pipeline_editor « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa1c70c1994ce2677e6933c9e8f9da4ed56da2ab (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import axios from '~/lib/utils/axios_utils';
import getAppStatus from './queries/client/app_status.query.graphql';
import getCurrentBranch from './queries/client/current_branch.query.graphql';
import getLastCommitBranch from './queries/client/last_commit_branch.query.graphql';
import getPipelineEtag from './queries/client/pipeline_etag.query.graphql';

export const resolvers = {
  Mutation: {
    lintCI: (_, { endpoint, content, dry_run }) => {
      return axios.post(endpoint, { content, dry_run }).then(({ data }) => ({
        valid: data.valid,
        errors: data.errors,
        warnings: data.warnings,
        jobs: data.jobs.map((job) => {
          const only = job.only ? { refs: job.only.refs, __typename: 'CiLintJobOnlyPolicy' } : null;

          return {
            name: job.name,
            stage: job.stage,
            beforeScript: job.before_script,
            script: job.script,
            afterScript: job.after_script,
            tags: job.tag_list,
            environment: job.environment,
            when: job.when,
            allowFailure: job.allow_failure,
            only,
            except: job.except,
            __typename: 'CiLintJob',
          };
        }),
        __typename: 'CiLintContent',
      }));
    },
    updateAppStatus: (_, { appStatus }, { cache }) => {
      cache.writeQuery({
        query: getAppStatus,
        data: {
          app: {
            __typename: 'PipelineEditorApp',
            status: appStatus,
          },
        },
      });
    },
    updateCurrentBranch: (_, { currentBranch }, { cache }) => {
      cache.writeQuery({
        query: getCurrentBranch,
        data: {
          workBranches: {
            __typename: 'BranchList',
            current: {
              __typename: 'WorkBranch',
              name: currentBranch,
            },
          },
        },
      });
    },
    updateLastCommitBranch: (_, { lastCommitBranch }, { cache }) => {
      cache.writeQuery({
        query: getLastCommitBranch,
        data: {
          workBranches: {
            __typename: 'BranchList',
            lastCommit: {
              __typename: 'WorkBranch',
              name: lastCommitBranch,
            },
          },
        },
      });
    },
    updatePipelineEtag: (_, { pipelineEtag }, { cache }) => {
      cache.writeQuery({
        query: getPipelineEtag,
        data: {
          etags: {
            __typename: 'EtagValues',
            pipeline: pipelineEtag,
          },
        },
      });
    },
  },
};