Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use keystone.executeGraphQL in test-utils #3159

Merged
merged 1 commit into from Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/tiny-bikes-join.md
@@ -0,0 +1,6 @@
---
'@keystonejs/test-utils': major
---

Updated to use `keystone.executeGraphQL` for all server-side GraphQL operations.
Removed the `operationName` argument from `graphqlRequest` and `authedGraphqlRequest`.
22 changes: 16 additions & 6 deletions packages/test-utils/lib/test-utils.js
Expand Up @@ -61,15 +61,25 @@ async function setupServer({
return { keystone, app };
}

function graphqlRequest({ keystone, query, variables, operationName }) {
return keystone.executeQuery(query, { variables, operationName });
function graphqlRequest({ keystone, query, variables }) {
return keystone.executeGraphQL({
context: keystone.createContext({ schemaName: 'testing', skipAccessControl: true }),
query,
variables,
});
}

// This is much like graphqlRequest except we don't skip access control checks!
function authedGraphqlRequest({ keystone, query, variables, operationName }) {
const context = keystone.getGraphQlContext({ schemaName: 'testing' });
const executeQuery = keystone._buildQueryHelper(context);
return executeQuery(query, { variables, operationName });
function authedGraphqlRequest({ keystone, query, variables }) {
return keystone.executeGraphQL({
context: keystone.createContext({
schemaName: 'testing',
authentication: {},
skipAccessControl: false,
}),
query,
variables,
});
}

function networkedGraphqlRequest({
Expand Down