@@ -50,7 +50,6 @@ import { assertValidSchema } from '../type/validate.js';
50
50
51
51
import type { DeferUsageSet , ExecutionPlan } from './buildExecutionPlan.js' ;
52
52
import { buildExecutionPlan } from './buildExecutionPlan.js' ;
53
- import { Canceller } from './Canceller.js' ;
54
53
import type {
55
54
DeferUsage ,
56
55
FieldDetailsList ,
@@ -64,6 +63,7 @@ import {
64
63
import { getVariableSignature } from './getVariableSignature.js' ;
65
64
import { buildIncrementalResponse } from './IncrementalPublisher.js' ;
66
65
import { mapAsyncIterable } from './mapAsyncIterable.js' ;
66
+ import { PromiseCanceller } from './PromiseCanceller.js' ;
67
67
import type {
68
68
CancellableStreamRecord ,
69
69
CompletedExecutionGroup ,
@@ -164,7 +164,7 @@ export interface ValidatedExecutionArgs {
164
164
export interface ExecutionContext {
165
165
validatedExecutionArgs : ValidatedExecutionArgs ;
166
166
errors : Array < GraphQLError > | undefined ;
167
- canceller : Canceller | undefined ;
167
+ promiseCanceller : PromiseCanceller | undefined ;
168
168
cancellableStreams : Set < CancellableStreamRecord > | undefined ;
169
169
}
170
170
@@ -316,7 +316,9 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
316
316
const exeContext : ExecutionContext = {
317
317
validatedExecutionArgs,
318
318
errors : undefined ,
319
- canceller : abortSignal ? new Canceller ( abortSignal ) : undefined ,
319
+ promiseCanceller : abortSignal
320
+ ? new PromiseCanceller ( abortSignal )
321
+ : undefined ,
320
322
cancellableStreams : undefined ,
321
323
} ;
322
324
try {
@@ -369,7 +371,7 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
369
371
return graphqlWrappedResult . then (
370
372
( resolved ) => buildDataResponse ( exeContext , resolved ) ,
371
373
( error : unknown ) => {
372
- exeContext . canceller ?. unsubscribe ( ) ;
374
+ exeContext . promiseCanceller ?. disconnect ( ) ;
373
375
return {
374
376
data : null ,
375
377
errors : withError ( exeContext . errors , error as GraphQLError ) ,
@@ -381,7 +383,7 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
381
383
} catch ( error ) {
382
384
// TODO: add test case for synchronous null bubbling to root with cancellation
383
385
/* c8 ignore next */
384
- exeContext . canceller ?. unsubscribe ( ) ;
386
+ exeContext . promiseCanceller ?. disconnect ( ) ;
385
387
return { data : null , errors : withError ( exeContext . errors , error ) } ;
386
388
}
387
389
}
@@ -472,7 +474,7 @@ function buildDataResponse(
472
474
const { rawResult : data , incrementalDataRecords } = graphqlWrappedResult ;
473
475
const errors = exeContext . errors ;
474
476
if ( incrementalDataRecords === undefined ) {
475
- exeContext . canceller ?. unsubscribe ( ) ;
477
+ exeContext . promiseCanceller ?. disconnect ( ) ;
476
478
return errors !== undefined ? { errors, data } : { data } ;
477
479
}
478
480
@@ -823,7 +825,7 @@ function executeField(
823
825
incrementalContext : IncrementalContext | undefined ,
824
826
deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
825
827
) : PromiseOrValue < GraphQLWrappedResult < unknown > > | undefined {
826
- const { validatedExecutionArgs, canceller } = exeContext ;
828
+ const { validatedExecutionArgs, promiseCanceller } = exeContext ;
827
829
const { schema, contextValue, variableValues, hideSuggestions, abortSignal } =
828
830
validatedExecutionArgs ;
829
831
const fieldName = fieldDetailsList [ 0 ] . node . name . value ;
@@ -868,7 +870,7 @@ function executeField(
868
870
fieldDetailsList ,
869
871
info ,
870
872
path ,
871
- canceller ?. withCancellation ( result ) ?? result ,
873
+ promiseCanceller ?. withCancellation ( result ) ?? result ,
872
874
incrementalContext ,
873
875
deferMap ,
874
876
) ;
@@ -2203,17 +2205,19 @@ function executeSubscription(
2203
2205
const result = resolveFn ( rootValue , args , contextValue , info , abortSignal ) ;
2204
2206
2205
2207
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 ;
2208
2212
return promise . then ( assertEventStream ) . then (
2209
2213
( resolved ) => {
2210
2214
// TODO: add test case
2211
2215
/* c8 ignore next */
2212
- canceller ?. unsubscribe ( ) ;
2216
+ promiseCanceller ?. disconnect ( ) ;
2213
2217
return resolved ;
2214
2218
} ,
2215
2219
( error : unknown ) => {
2216
- canceller ?. unsubscribe ( ) ;
2220
+ promiseCanceller ?. disconnect ( ) ;
2217
2221
throw locatedError ( error , fieldNodes , pathToArray ( path ) ) ;
2218
2222
} ,
2219
2223
) ;
0 commit comments