diff options
Diffstat (limited to 'spec/frontend_integration/test_helpers/mock_server/graphql.js')
-rw-r--r-- | spec/frontend_integration/test_helpers/mock_server/graphql.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/frontend_integration/test_helpers/mock_server/graphql.js b/spec/frontend_integration/test_helpers/mock_server/graphql.js new file mode 100644 index 00000000000..6dcc4798378 --- /dev/null +++ b/spec/frontend_integration/test_helpers/mock_server/graphql.js @@ -0,0 +1,21 @@ +import { buildSchema, graphql } from 'graphql'; +import gitlabSchemaStr from '../../../../doc/api/graphql/reference/gitlab_schema.graphql'; + +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, + }, + }; + }, +}; + +// eslint-disable-next-line import/prefer-default-export +export const graphqlQuery = (query, variables, schema) => + graphql(graphqlSchema, query, graphqlResolvers, schema, variables); |