Skip to content

Commit 610c76a

Browse files
committed
rename + update docs
1 parent 531c6a2 commit 610c76a

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

src/execution/__tests__/executor-test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ describe('Execute: Handles basic execution tasks', () => {
13561356
}
13571357
`);
13581358

1359-
const executionOptions = {
1359+
const options = {
13601360
maxCoercionErrors: 1,
13611361
};
13621362

@@ -1371,13 +1371,11 @@ describe('Execute: Handles basic execution tasks', () => {
13711371
wrongArg3: 'wrong',
13721372
},
13731373
},
1374-
executionOptions,
1374+
options,
13751375
});
13761376

13771377
// Returns at least 2 errors, one for the first 'wrongArg', and one for coercion limit
1378-
expect(result.errors).to.have.lengthOf(
1379-
executionOptions.maxCoercionErrors + 1,
1380-
);
1378+
expect(result.errors).to.have.lengthOf(options.maxCoercionErrors + 1);
13811379
expect(
13821380
result.errors && result.errors.length > 0
13831381
? result.errors[result.errors.length - 1].message

src/execution/execute.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ export interface ExecutionArgs {
152152
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
153153
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
154154
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
155-
executionOptions?: {
155+
/** Additional execution options. */
156+
options?: {
157+
/** Set the maximum number of errors allowed for coercing (defaults to 50). */
156158
maxCoercionErrors?: number;
157159
};
158160
}
@@ -289,7 +291,7 @@ export function buildExecutionContext(
289291
fieldResolver,
290292
typeResolver,
291293
subscribeFieldResolver,
292-
executionOptions,
294+
options,
293295
} = args;
294296

295297
let operation: OperationDefinitionNode | undefined;
@@ -333,7 +335,7 @@ export function buildExecutionContext(
333335
schema,
334336
variableDefinitions,
335337
rawVariableValues ?? {},
336-
{ maxErrors: executionOptions?.maxCoercionErrors ?? 50 },
338+
{ maxErrors: options?.maxCoercionErrors ?? 50 },
337339
);
338340

339341
if (coercedVariableValues.errors) {

website/pages/api-v16/execution.mdx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ const { execute } = require('graphql'); // CommonJS
2929
### execute
3030

3131
```ts
32-
export function execute(
32+
export function execute({
3333
schema: GraphQLSchema,
34-
documentAST: Document,
35-
rootValue?: mixed,
36-
contextValue?: mixed,
34+
document: DocumentNode,
35+
rootValue?: unknown,
36+
contextValue?: unknown,
3737
variableValues?: { [key: string]: mixed },
3838
operationName?: string,
39-
): MaybePromise<ExecutionResult>;
39+
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
40+
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
41+
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
42+
options?: { maxCoercionErrors?: number };
43+
}): PromiseOrValue<ExecutionResult>;
4044

41-
type MaybePromise<T> = Promise<T> | T;
45+
type PromiseOrValue<T> = Promise<T> | T;
4246

4347
interface ExecutionResult<
4448
TData = ObjMap<unknown>,
@@ -61,21 +65,32 @@ a GraphQLError will be thrown immediately explaining the invalid input.
6165
executing the query, `errors` is null if no errors occurred, and is a
6266
non-empty array if an error occurred.
6367

68+
#### options
69+
70+
##### maxCoercionErrors
71+
72+
Set the maximum number of errors allowed for coercing (defaults to 50).
73+
6474
### executeSync
6575

6676
```ts
67-
export function executeSync(
77+
export function executeSync({
6878
schema: GraphQLSchema,
69-
documentAST: Document,
70-
rootValue?: mixed,
71-
contextValue?: mixed,
79+
document: DocumentNode,
80+
rootValue?: unknown,
81+
contextValue?: unknown,
7282
variableValues?: { [key: string]: mixed },
7383
operationName?: string,
74-
): ExecutionResult;
84+
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
85+
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
86+
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
87+
options?: { maxCoercionErrors?: number };
88+
}): ExecutionResult;
7589

7690
type ExecutionResult = {
77-
data: Object;
78-
errors?: GraphQLError[];
91+
errors?: ReadonlyArray<GraphQLError>;
92+
data?: TData | null;
93+
extensions?: TExtensions;
7994
};
8095
```
8196

0 commit comments

Comments
 (0)