summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipeline_new/graphql/resolvers.js
blob: 7b0f58e8cf97e313ee0c8aeffea6965c55c6f6be (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
import axios from '~/lib/utils/axios_utils';

export const resolvers = {
  Mutation: {
    createPipeline: (_, { endpoint, ref, variablesAttributes }) => {
      return axios
        .post(endpoint, { ref, variables_attributes: variablesAttributes })
        .then((response) => {
          const { id } = response.data;
          return {
            id,
            errors: [],
            totalWarnings: 0,
            warnings: [],
          };
        })
        .catch((err) => {
          const { errors = [], totalWarnings = 0, warnings = [] } = err.response.data;

          return {
            id: null,
            errors,
            totalWarnings,
            warnings,
          };
        });
    },
  },
};