Welcome to mirror list, hosted at ThFree Co, Russian Federation.

graphql.js « mock_server « test_helpers « frontend_integration « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e265885259974d53b5f65e9852d60a95700261af (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
import { buildSchema, graphql } from 'graphql';

/* eslint-disable import/no-unresolved */
// This rule is disabled for the following line.
// The graphql schema is dynamically generated in CI
// during the `graphql-schema-dump` job.
import gitlabSchemaStr from '../../../../tmp/tests/graphql/gitlab_schema.graphql';
/* eslint-enable import/no-unresolved */

const graphqlSchema = buildSchema(gitlabSchemaStr.loc.source.body);
const graphqlResolvers = {
  project({ fullPath }, schema) {
    const result = schema.projects.findBy({ path_with_namespace: fullPath });
    const userPermission = schema.db.userPermissions[0];

    return {
      ...result.attrs,
      userPermissions: {
        ...userPermission,
      },
    };
  },
};

export const graphqlQuery = (query, variables, schema) =>
  graphql(graphqlSchema, query, graphqlResolvers, schema, variables);