@@ -55,6 +55,8 @@ import {
5555 collectSubfields as _collectSubfields ,
5656} from './collectFields.js' ;
5757import { collectIteratorPromises } from './collectIteratorPromises.js' ;
58+ import type { SharedExecutionContext } from './createSharedExecutionContext.js' ;
59+ import { createSharedExecutionContext } from './createSharedExecutionContext.js' ;
5860import { buildResolveInfo } from './execute.js' ;
5961import type { StreamUsage } from './getStreamUsage.js' ;
6062import { getStreamUsage as _getStreamUsage } from './getStreamUsage.js' ;
@@ -224,26 +226,31 @@ export class Executor<
224226 validatedExecutionArgs : ValidatedExecutionArgs ;
225227 aborted : boolean ;
226228 abortReason : unknown ;
229+ sharedExecutionContext : SharedExecutionContext ;
227230 collectedErrors : CollectedErrors ;
228231 abortResultPromise : ( ( reason ?: unknown ) => void ) | undefined ;
229232 resolverAbortController : AbortController | undefined ;
230- sharedResolverAbortSignal : AbortSignal ;
233+ getAbortSignal : ( ) => AbortSignal | undefined ;
231234
232235 constructor (
233236 validatedExecutionArgs : ValidatedExecutionArgs ,
234- sharedResolverAbortSignal ?: AbortSignal ,
237+ sharedExecutionContext ?: SharedExecutionContext ,
235238 ) {
236239 this . validatedExecutionArgs = validatedExecutionArgs ;
237240 this . aborted = false ;
238241 this . abortReason = new Error ( 'This operation was aborted' ) ;
239242 this . collectedErrors = new CollectedErrors ( ) ;
240243
241- if ( sharedResolverAbortSignal === undefined ) {
244+ if ( sharedExecutionContext === undefined ) {
242245 this . resolverAbortController = new AbortController ( ) ;
243- this . sharedResolverAbortSignal = this . resolverAbortController . signal ;
246+ this . sharedExecutionContext = createSharedExecutionContext (
247+ this . resolverAbortController . signal ,
248+ ) ;
244249 } else {
245- this . sharedResolverAbortSignal = sharedResolverAbortSignal ;
250+ this . sharedExecutionContext = sharedExecutionContext ;
246251 }
252+ const { getAbortSignal } = this . sharedExecutionContext ;
253+ this . getAbortSignal = getAbortSignal ;
247254 }
248255
249256 executeQueryOrMutationOrSubscriptionEvent ( ) : PromiseOrValue <
@@ -553,7 +560,7 @@ export class Executor<
553560 toNodes ( fieldDetailsList ) ,
554561 parentType ,
555562 path ,
556- ( ) => this . sharedResolverAbortSignal ,
563+ this . getAbortSignal ,
557564 ) ;
558565
559566 // Get the resolve function, regardless of if its result is normal or abrupt (error).
0 commit comments