@@ -50,7 +50,6 @@ import { assertValidSchema } from '../type/validate.js';
5050
5151import type { DeferUsageSet , ExecutionPlan } from './buildExecutionPlan.js' ;
5252import { buildExecutionPlan } from './buildExecutionPlan.js' ;
53- import { Canceller } from './Canceller.js' ;
5453import type {
5554 DeferUsage ,
5655 FieldDetailsList ,
@@ -64,6 +63,7 @@ import {
6463import { getVariableSignature } from './getVariableSignature.js' ;
6564import { buildIncrementalResponse } from './IncrementalPublisher.js' ;
6665import { mapAsyncIterable } from './mapAsyncIterable.js' ;
66+ import { PromiseCanceller } from './PromiseCanceller.js' ;
6767import type {
6868 CancellableStreamRecord ,
6969 CompletedExecutionGroup ,
@@ -164,7 +164,7 @@ export interface ValidatedExecutionArgs {
164164export interface ExecutionContext {
165165 validatedExecutionArgs : ValidatedExecutionArgs ;
166166 errors : Array < GraphQLError > | undefined ;
167- canceller : Canceller | undefined ;
167+ promiseCanceller : PromiseCanceller | undefined ;
168168 cancellableStreams : Set < CancellableStreamRecord > | undefined ;
169169}
170170
@@ -316,7 +316,9 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
316316 const exeContext : ExecutionContext = {
317317 validatedExecutionArgs,
318318 errors : undefined ,
319- canceller : abortSignal ? new Canceller ( abortSignal ) : undefined ,
319+ promiseCanceller : abortSignal
320+ ? new PromiseCanceller ( abortSignal )
321+ : undefined ,
320322 cancellableStreams : undefined ,
321323 } ;
322324 try {
@@ -369,7 +371,7 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
369371 return graphqlWrappedResult . then (
370372 ( resolved ) => buildDataResponse ( exeContext , resolved ) ,
371373 ( error : unknown ) => {
372- exeContext . canceller ?. unsubscribe ( ) ;
374+ exeContext . promiseCanceller ?. disconnect ( ) ;
373375 return {
374376 data : null ,
375377 errors : withError ( exeContext . errors , error as GraphQLError ) ,
@@ -381,7 +383,7 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
381383 } catch ( error ) {
382384 // TODO: add test case for synchronous null bubbling to root with cancellation
383385 /* c8 ignore next */
384- exeContext . canceller ?. unsubscribe ( ) ;
386+ exeContext . promiseCanceller ?. disconnect ( ) ;
385387 return { data : null , errors : withError ( exeContext . errors , error ) } ;
386388 }
387389}
@@ -472,7 +474,7 @@ function buildDataResponse(
472474 const { rawResult : data , incrementalDataRecords } = graphqlWrappedResult ;
473475 const errors = exeContext . errors ;
474476 if ( incrementalDataRecords === undefined ) {
475- exeContext . canceller ?. unsubscribe ( ) ;
477+ exeContext . promiseCanceller ?. disconnect ( ) ;
476478 return errors !== undefined ? { errors, data } : { data } ;
477479 }
478480
@@ -823,7 +825,7 @@ function executeField(
823825 incrementalContext : IncrementalContext | undefined ,
824826 deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
825827) : PromiseOrValue < GraphQLWrappedResult < unknown > > | undefined {
826- const { validatedExecutionArgs, canceller } = exeContext ;
828+ const { validatedExecutionArgs, promiseCanceller } = exeContext ;
827829 const { schema, contextValue, variableValues, hideSuggestions, abortSignal } =
828830 validatedExecutionArgs ;
829831 const fieldName = fieldDetailsList [ 0 ] . node . name . value ;
@@ -868,7 +870,7 @@ function executeField(
868870 fieldDetailsList ,
869871 info ,
870872 path ,
871- canceller ?. withCancellation ( result ) ?? result ,
873+ promiseCanceller ?. withCancellation ( result ) ?? result ,
872874 incrementalContext ,
873875 deferMap ,
874876 ) ;
@@ -2203,17 +2205,19 @@ function executeSubscription(
22032205 const result = resolveFn ( rootValue , args , contextValue , info , abortSignal ) ;
22042206
22052207 if ( isPromise ( result ) ) {
2206- const canceller = abortSignal ? new Canceller ( abortSignal ) : undefined ;
2207- const promise = canceller ?. withCancellation ( result ) ?? result ;
2208+ const promiseCanceller = abortSignal
2209+ ? new PromiseCanceller ( abortSignal )
2210+ : undefined ;
2211+ const promise = promiseCanceller ?. withCancellation ( result ) ?? result ;
22082212 return promise . then ( assertEventStream ) . then (
22092213 ( resolved ) => {
22102214 // TODO: add test case
22112215 /* c8 ignore next */
2212- canceller ?. unsubscribe ( ) ;
2216+ promiseCanceller ?. disconnect ( ) ;
22132217 return resolved ;
22142218 } ,
22152219 ( error : unknown ) => {
2216- canceller ?. unsubscribe ( ) ;
2220+ promiseCanceller ?. disconnect ( ) ;
22172221 throw locatedError ( error , fieldNodes , pathToArray ( path ) ) ;
22182222 } ,
22192223 ) ;
0 commit comments