Skip to content

Commit ccd2a3f

Browse files
igor.luckenkovIvanGoncharov
authored andcommitted
accept signal in graphql function and pass it down to execute
1 parent 8babb2f commit ccd2a3f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/execution/execute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export interface ExecutionArgs {
271271
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
272272
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
273273
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
274-
signal?: IAbortSignal;
274+
signal?: Maybe<IAbortSignal>;
275275
}
276276

277277
const UNEXPECTED_EXPERIMENTAL_DIRECTIVES =

src/graphql.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { IAbortSignal } from './jsutils/AbortController';
12
import { isPromise } from './jsutils/isPromise.js';
23
import type { Maybe } from './jsutils/Maybe.js';
34
import type { PromiseOrValue } from './jsutils/PromiseOrValue.js';
@@ -57,6 +58,9 @@ import { execute } from './execution/execute.js';
5758
* A type resolver function to use when none is provided by the schema.
5859
* If not provided, the default type resolver is used (which looks for a
5960
* `__typename` field or alternatively calls the `isTypeOf` method).
61+
* signal:
62+
* An AbortSignal that can be used to abort the execution of the query.
63+
* If the signal is aborted, the execution will stop and an abort error will be thrown.
6064
*/
6165
export interface GraphQLArgs {
6266
schema: GraphQLSchema;
@@ -67,6 +71,7 @@ export interface GraphQLArgs {
6771
operationName?: Maybe<string>;
6872
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
6973
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
74+
signal?: IAbortSignal;
7075
}
7176

7277
export function graphql(args: GraphQLArgs): Promise<ExecutionResult> {
@@ -101,6 +106,7 @@ function graphqlImpl(args: GraphQLArgs): PromiseOrValue<ExecutionResult> {
101106
operationName,
102107
fieldResolver,
103108
typeResolver,
109+
signal,
104110
} = args;
105111

106112
// Validate Schema
@@ -133,5 +139,6 @@ function graphqlImpl(args: GraphQLArgs): PromiseOrValue<ExecutionResult> {
133139
operationName,
134140
fieldResolver,
135141
typeResolver,
142+
signal,
136143
});
137144
}

0 commit comments

Comments
 (0)