@@ -13,7 +13,6 @@ import { addPath, pathToArray } from '../jsutils/Path.js';
1313import { promiseForObject } from '../jsutils/promiseForObject.js' ;
1414import type { PromiseOrValue } from '../jsutils/PromiseOrValue.js' ;
1515import { promiseReduce } from '../jsutils/promiseReduce.js' ;
16- import { promiseWithResolvers } from '../jsutils/promiseWithResolvers.js' ;
1716
1817import { GraphQLError } from '../error/GraphQLError.js' ;
1918import { locatedError } from '../error/locatedError.js' ;
@@ -868,42 +867,41 @@ function executeField(
868867 const result = resolveFn ( source , args , contextValue , info , abortSignal ) ;
869868
870869 if ( isPromise ( result ) ) {
871- const { promise, resolve, reject } =
872- promiseWithResolvers < GraphQLWrappedResult < unknown > > ( ) ;
873- abortSignal ?. addEventListener (
874- 'abort' ,
875- ( ) => {
876- try {
877- resolve ( {
878- rawResult : null ,
879- incrementalDataRecords : undefined ,
880- errors : [
881- buildFieldError (
882- abortSignal . reason ,
883- returnType ,
884- fieldDetailsList ,
885- path ,
886- ) ,
887- ] ,
888- } ) ;
889- } catch ( error ) {
890- reject ( error ) ;
891- }
892- } ,
893- { once : true } ,
894- ) ;
895- completePromisedValue (
896- exeContext ,
897- returnType ,
898- fieldDetailsList ,
899- info ,
900- path ,
901- result ,
902- incrementalContext ,
903- deferMap ,
904- // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
905- ) . then ( resolve , reject ) ;
906- return promise ;
870+ return new Promise ( ( resolve , reject ) => {
871+ abortSignal ?. addEventListener (
872+ 'abort' ,
873+ ( ) => {
874+ try {
875+ resolve ( {
876+ rawResult : null ,
877+ incrementalDataRecords : undefined ,
878+ errors : [
879+ buildFieldError (
880+ abortSignal . reason ,
881+ returnType ,
882+ fieldDetailsList ,
883+ path ,
884+ ) ,
885+ ] ,
886+ } ) ;
887+ } catch ( error ) {
888+ reject ( error as GraphQLError ) ;
889+ }
890+ } ,
891+ { once : true } ,
892+ ) ;
893+ completePromisedValue (
894+ exeContext ,
895+ returnType ,
896+ fieldDetailsList ,
897+ info ,
898+ path ,
899+ result ,
900+ incrementalContext ,
901+ deferMap ,
902+ // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
903+ ) . then ( resolve , reject ) ;
904+ } ) ;
907905 }
908906
909907 const completed = completeValue (
@@ -2206,19 +2204,18 @@ function executeSubscription(
22062204 const result = resolveFn ( rootValue , args , contextValue , info , abortSignal ) ;
22072205
22082206 if ( isPromise ( result ) ) {
2209- const { promise, resolve, reject } = promiseWithResolvers < unknown > ( ) ;
2210- abortSignal ?. addEventListener (
2211- 'abort' ,
2212- ( ) =>
2213- reject (
2214- locatedError ( abortSignal . reason , fieldNodes , pathToArray ( path ) ) ,
2215- ) ,
2216- { once : true } ,
2217- ) ;
2218- // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
2219- result . then ( resolve , reject ) ;
2220-
2221- return promise
2207+ return new Promise ( ( resolve , reject ) => {
2208+ abortSignal ?. addEventListener (
2209+ 'abort' ,
2210+ ( ) =>
2211+ reject (
2212+ locatedError ( abortSignal . reason , fieldNodes , pathToArray ( path ) ) ,
2213+ ) ,
2214+ { once : true } ,
2215+ ) ;
2216+ // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
2217+ result . then ( resolve , reject ) ;
2218+ } )
22222219 . then ( assertEventStream )
22232220 . then ( undefined , ( error : unknown ) => {
22242221 throw locatedError ( error , fieldNodes , pathToArray ( path ) ) ;
0 commit comments