Skip to content

Commit

Permalink
Remove context arg from raw() and run() (#4945)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Feb 25, 2021
1 parent 6dcd01c commit 24e0ef5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/modern-squids-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@keystone-next/keystone': major
'@keystone-next/types': major
---

Removed the `context` argument from `KeystoneContext.graphql.raw` and `KeystoneContext.graphql.run`.
8 changes: 4 additions & 4 deletions packages-next/keystone/src/lib/createContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ export function makeCreateContext({
skipAccessControl?: boolean;
req?: IncomingMessage;
} = {}): KeystoneContext => {
const rawGraphQL: KeystoneGraphQLAPI<any>['raw'] = ({ query, context, variables }) => {
const rawGraphQL: KeystoneGraphQLAPI<any>['raw'] = ({ query, variables }) => {
if (typeof query === 'string') {
query = parse(query);
}
return Promise.resolve(
execute({
schema: graphQLSchema,
document: query,
contextValue: context ?? contextToReturn,
contextValue: contextToReturn,
variableValues: variables,
})
);
};
const runGraphQL: KeystoneGraphQLAPI<any>['run'] = async args => {
let result = await rawGraphQL(args);
const runGraphQL: KeystoneGraphQLAPI<any>['run'] = async ({ query, variables }) => {
let result = await rawGraphQL({ query, variables });
if (result.errors?.length) {
throw result.errors[0];
}
Expand Down
1 change: 0 additions & 1 deletion packages-next/types/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export type KeystoneGraphQLAPI<
};

type GraphQLExecutionArguments = {
context?: any;
query: string | DocumentNode;
variables: Record<string, any>;
};
Expand Down

1 comment on commit 24e0ef5

@vercel
Copy link

@vercel vercel bot commented on 24e0ef5 Feb 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.