-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(execution): add max coercion errors option to execution context #4366
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
Changes from 2 commits
531c6a2
610c76a
e6789ef
0231740
7911bc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,16 +29,20 @@ const { execute } = require('graphql'); // CommonJS | |
### execute | ||
|
||
```ts | ||
export function execute( | ||
export function execute({ | ||
schema: GraphQLSchema, | ||
documentAST: Document, | ||
rootValue?: mixed, | ||
contextValue?: mixed, | ||
document: DocumentNode, | ||
rootValue?: unknown, | ||
contextValue?: unknown, | ||
variableValues?: { [key: string]: mixed }, | ||
operationName?: string, | ||
): MaybePromise<ExecutionResult>; | ||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>; | ||
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>; | ||
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>; | ||
options?: { maxCoercionErrors?: number }; | ||
}): PromiseOrValue<ExecutionResult>; | ||
|
||
type MaybePromise<T> = Promise<T> | T; | ||
type PromiseOrValue<T> = Promise<T> | T; | ||
|
||
interface ExecutionResult< | ||
TData = ObjMap<unknown>, | ||
|
@@ -61,21 +65,32 @@ a GraphQLError will be thrown immediately explaining the invalid input. | |
executing the query, `errors` is null if no errors occurred, and is a | ||
non-empty array if an error occurred. | ||
|
||
#### options | ||
|
||
##### maxCoercionErrors | ||
|
||
Set the maximum number of errors allowed for coercing (defaults to 50). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we leave the rest of the docs untouched, the changes seem invalid 😅 like from where I sit the only thing that we need to add is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are wrong. I cannot add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the code:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fair but the docs should still show both methods rather than this kind of driveby change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have reverted the changes to the docs. My only concern now is that this new options are only documented in the code, so not sure how many people will benefit from them... It would be nice to update the docs for v17. |
||
|
||
### executeSync | ||
|
||
```ts | ||
export function executeSync( | ||
export function executeSync({ | ||
schema: GraphQLSchema, | ||
documentAST: Document, | ||
rootValue?: mixed, | ||
contextValue?: mixed, | ||
document: DocumentNode, | ||
rootValue?: unknown, | ||
contextValue?: unknown, | ||
variableValues?: { [key: string]: mixed }, | ||
operationName?: string, | ||
): ExecutionResult; | ||
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>; | ||
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>; | ||
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>; | ||
options?: { maxCoercionErrors?: number }; | ||
}): ExecutionResult; | ||
|
||
type ExecutionResult = { | ||
data: Object; | ||
errors?: GraphQLError[]; | ||
errors?: ReadonlyArray<GraphQLError>; | ||
data?: TData | null; | ||
extensions?: TExtensions; | ||
}; | ||
``` | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this object syntax wasn't intended