2020-10-30 21:08:52 +00:00
|
|
|
import Api from '~/api';
|
2020-11-27 12:09:14 +00:00
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2020-10-30 21:08:52 +00:00
|
|
|
|
|
|
|
export const resolvers = {
|
|
|
|
Query: {
|
|
|
|
blobContent(_, { projectPath, path, ref }) {
|
|
|
|
return {
|
|
|
|
__typename: 'BlobContent',
|
|
|
|
rawData: Api.getRawFile(projectPath, path, { ref }).then(({ data }) => {
|
|
|
|
return data;
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
},
|
2021-04-09 18:09:24 +00:00
|
|
|
/* eslint-disable @gitlab/require-i18n-strings */
|
|
|
|
project() {
|
|
|
|
return {
|
|
|
|
__typename: 'Project',
|
|
|
|
repository: {
|
|
|
|
__typename: 'Repository',
|
|
|
|
branches: [
|
|
|
|
{ __typename: 'Branch', name: 'master' },
|
|
|
|
{ __typename: 'Branch', name: 'main' },
|
|
|
|
{ __typename: 'Branch', name: 'develop' },
|
|
|
|
{ __typename: 'Branch', name: 'production' },
|
|
|
|
{ __typename: 'Branch', name: 'test' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
/* eslint-enable @gitlab/require-i18n-strings */
|
2020-10-30 21:08:52 +00:00
|
|
|
},
|
2020-11-27 12:09:14 +00:00
|
|
|
Mutation: {
|
|
|
|
lintCI: (_, { endpoint, content, dry_run }) => {
|
|
|
|
return axios.post(endpoint, { content, dry_run }).then(({ data }) => ({
|
|
|
|
valid: data.valid,
|
|
|
|
errors: data.errors,
|
|
|
|
warnings: data.warnings,
|
2020-12-24 00:10:25 +00:00
|
|
|
jobs: data.jobs.map((job) => {
|
2020-11-27 12:09:14 +00:00
|
|
|
const only = job.only ? { refs: job.only.refs, __typename: 'CiLintJobOnlyPolicy' } : null;
|
2020-10-30 21:08:52 +00:00
|
|
|
|
2020-11-27 12:09:14 +00:00
|
|
|
return {
|
|
|
|
name: job.name,
|
|
|
|
stage: job.stage,
|
|
|
|
beforeScript: job.before_script,
|
|
|
|
script: job.script,
|
|
|
|
afterScript: job.after_script,
|
2021-01-13 15:10:40 +00:00
|
|
|
tags: job.tag_list,
|
2020-11-27 12:09:14 +00:00
|
|
|
environment: job.environment,
|
|
|
|
when: job.when,
|
|
|
|
allowFailure: job.allow_failure,
|
|
|
|
only,
|
|
|
|
except: job.except,
|
|
|
|
__typename: 'CiLintJob',
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
__typename: 'CiLintContent',
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|