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

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-01-29 00:20:46 +05:30
import Api from '~/api';
2021-02-22 17:27:13 +05:30
import axios from '~/lib/utils/axios_utils';
2021-01-29 00:20:46 +05:30
export const resolvers = {
Query: {
blobContent(_, { projectPath, path, ref }) {
return {
__typename: 'BlobContent',
rawData: Api.getRawFile(projectPath, path, { ref }).then(({ data }) => {
return data;
}),
};
},
},
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',
}));
},
},
};