debian-mirror-gitlab/app/assets/javascripts/pipeline_editor/graphql/resolvers.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2.5 KiB
JavaScript
Raw Normal View History

2021-02-22 17:27:13 +05:30
import axios from '~/lib/utils/axios_utils';
2022-01-26 12:08:38 +05:30
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';
2021-01-29 00:20:46 +05:30
export const resolvers = {
2021-02-22 17:27:13 +05:30
Mutation: {
lintCI: (_, { endpoint, content, dry_run }) => {
return axios.post(endpoint, { content, dry_run }).then(({ data }) => ({
valid: data.valid,
errors: data.errors,
warnings: data.warnings,
2021-03-08 18:12:59 +05:30
jobs: data.jobs.map((job) => {
2021-02-22 17:27:13 +05:30
const only = job.only ? { refs: job.only.refs, __typename: 'CiLintJobOnlyPolicy' } : null;
2021-01-29 00:20:46 +05:30
2021-02-22 17:27:13 +05:30
return {
name: job.name,
stage: job.stage,
beforeScript: job.before_script,
script: job.script,
afterScript: job.after_script,
2021-03-08 18:12:59 +05:30
tags: job.tag_list,
2021-02-22 17:27:13 +05:30
environment: job.environment,
when: job.when,
allowFailure: job.allow_failure,
only,
except: job.except,
__typename: 'CiLintJob',
};
}),
__typename: 'CiLintContent',
}));
},
2021-12-11 22:18:48 +05:30
updateAppStatus: (_, { appStatus }, { cache }) => {
cache.writeQuery({
query: getAppStatus,
2022-01-26 12:08:38 +05:30
data: {
app: {
__typename: 'PipelineEditorApp',
status: appStatus,
},
},
2021-12-11 22:18:48 +05:30
});
},
2021-09-30 23:02:18 +05:30
updateCurrentBranch: (_, { currentBranch }, { cache }) => {
2021-09-04 01:27:46 +05:30
cache.writeQuery({
2022-01-26 12:08:38 +05:30
query: getCurrentBranch,
data: {
workBranches: {
__typename: 'BranchList',
current: {
__typename: 'WorkBranch',
name: currentBranch,
},
},
},
2021-09-04 01:27:46 +05:30
});
},
2021-09-30 23:02:18 +05:30
updateLastCommitBranch: (_, { lastCommitBranch }, { cache }) => {
2021-09-04 01:27:46 +05:30
cache.writeQuery({
2022-01-26 12:08:38 +05:30
query: getLastCommitBranch,
data: {
workBranches: {
__typename: 'BranchList',
lastCommit: {
__typename: 'WorkBranch',
name: lastCommitBranch,
},
},
},
2021-12-11 22:18:48 +05:30
});
},
updatePipelineEtag: (_, { pipelineEtag }, { cache }) => {
cache.writeQuery({
query: getPipelineEtag,
2022-01-26 12:08:38 +05:30
data: {
etags: {
__typename: 'EtagValues',
pipeline: pipelineEtag,
},
},
2021-09-04 01:27:46 +05:30
});
},
2021-02-22 17:27:13 +05:30
},
};