Skip to content

Commit 70f780e

Browse files
committed
feat: pass abortSignal to resolvers
this allows e.g. passing the signal to fetch
1 parent 9dae904 commit 70f780e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/execution/execute.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ function executeField(
798798
deferMap: ReadonlyMap<DeferUsage, DeferredFragmentRecord> | undefined,
799799
): PromiseOrValue<GraphQLWrappedResult<unknown>> | undefined {
800800
const validatedExecutionArgs = exeContext.validatedExecutionArgs;
801-
const { schema, contextValue, variableValues, hideSuggestions } =
801+
const { schema, contextValue, variableValues, hideSuggestions, abortSignal } =
802802
validatedExecutionArgs;
803803
const fieldName = fieldDetailsList[0].node.name.value;
804804
const fieldDef = schema.getField(parentType, fieldName);
@@ -833,7 +833,7 @@ function executeField(
833833
// The resolve function's optional third argument is a context value that
834834
// is provided to every resolve function within an execution. It is commonly
835835
// used to represent an authenticated user, or request-specific caches.
836-
const result = resolveFn(source, args, contextValue, info);
836+
const result = resolveFn(source, args, contextValue, info, abortSignal);
837837

838838
if (isPromise(result)) {
839839
return completePromisedValue(
@@ -2115,6 +2115,7 @@ function executeSubscription(
21152115
operation,
21162116
variableValues,
21172117
hideSuggestions,
2118+
abortSignal,
21182119
} = validatedExecutionArgs;
21192120

21202121
const rootType = schema.getSubscriptionType();
@@ -2180,7 +2181,7 @@ function executeSubscription(
21802181
// The resolve function's optional third argument is a context value that
21812182
// is provided to every resolve function within an execution. It is commonly
21822183
// used to represent an authenticated user, or request-specific caches.
2183-
const result = resolveFn(rootValue, args, contextValue, info);
2184+
const result = resolveFn(rootValue, args, contextValue, info, abortSignal);
21842185

21852186
if (isPromise(result)) {
21862187
return result

src/type/definition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ export type GraphQLFieldResolver<
990990
args: TArgs,
991991
context: TContext,
992992
info: GraphQLResolveInfo,
993+
abortSignal: AbortSignal | undefined,
993994
) => TResult;
994995

995996
export interface GraphQLResolveInfo {

0 commit comments

Comments
 (0)