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

61 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-02-22 17:27:13 +05:30
import axios from '~/lib/utils/axios_utils';
2021-12-11 22:18:48 +05:30
import getAppStatus from './queries/client/app_status.graphql';
2021-09-04 01:27:46 +05:30
import getCurrentBranchQuery from './queries/client/current_branch.graphql';
import getLastCommitBranchQuery from './queries/client/last_commit_branch.query.graphql';
2021-12-11 22:18:48 +05:30
import getPipelineEtag from './queries/client/pipeline_etag.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,
data: { appStatus },
});
},
2021-09-30 23:02:18 +05:30
updateCurrentBranch: (_, { currentBranch }, { cache }) => {
2021-09-04 01:27:46 +05:30
cache.writeQuery({
query: getCurrentBranchQuery,
2021-12-11 22:18:48 +05:30
data: { 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({
query: getLastCommitBranchQuery,
2021-12-11 22:18:48 +05:30
data: { lastCommitBranch },
});
},
updatePipelineEtag: (_, { pipelineEtag }, { cache }) => {
cache.writeQuery({
query: getPipelineEtag,
data: { pipelineEtag },
2021-09-04 01:27:46 +05:30
});
},
2021-02-22 17:27:13 +05:30
},
};