@@ -2099,13 +2099,6 @@ export function subscribe(
2099
2099
return mapSourceToResponse ( validatedExecutionArgs , resultOrStream ) ;
2100
2100
}
2101
2101
2102
- /**
2103
- *
2104
- * For each payload yielded from a subscription, map it over the normal
2105
- * GraphQL `execute` function, with `payload` as the rootValue.
2106
- * This implements the "MapSourceToResponseEvent" algorithm described in
2107
- * the GraphQL specification..
2108
- */
2109
2102
function mapSourceToResponse (
2110
2103
validatedExecutionArgs : ValidatedExecutionArgs ,
2111
2104
resultOrStream : ExecutionResult | AsyncIterable < unknown > ,
@@ -2115,28 +2108,25 @@ function mapSourceToResponse(
2115
2108
}
2116
2109
2117
2110
const abortSignal = validatedExecutionArgs . abortSignal ;
2118
- if ( abortSignal ) {
2119
- const promiseCanceller = new PromiseCanceller ( abortSignal ) ;
2120
- return mapAsyncIterable (
2121
- promiseCanceller ?. cancellableIterable ( resultOrStream ) ,
2122
- ( payload : unknown ) => {
2123
- const perEventExecutionArgs : ValidatedExecutionArgs = {
2124
- ...validatedExecutionArgs ,
2125
- rootValue : payload ,
2126
- } ;
2127
- return validatedExecutionArgs . perEventExecutor ( perEventExecutionArgs ) ;
2128
- } ,
2129
- ( ) => promiseCanceller . disconnect ( ) ,
2130
- ) ;
2131
- }
2132
2111
2133
- return mapAsyncIterable ( resultOrStream , ( payload : unknown ) => {
2134
- const perEventExecutionArgs : ValidatedExecutionArgs = {
2135
- ...validatedExecutionArgs ,
2136
- rootValue : payload ,
2137
- } ;
2138
- return validatedExecutionArgs . perEventExecutor ( perEventExecutionArgs ) ;
2139
- } ) ;
2112
+ const promiseCanceller = abortSignal
2113
+ ? new PromiseCanceller ( abortSignal )
2114
+ : undefined ;
2115
+ // For each payload yielded from a subscription, map it over the normal
2116
+ // GraphQL `execute` function, with `payload` as the rootValue.
2117
+ // This implements the "MapSourceToResponseEvent" algorithm described in
2118
+ // the GraphQL specification..
2119
+ return mapAsyncIterable (
2120
+ promiseCanceller ?. cancellableIterable ( resultOrStream ) ?? resultOrStream ,
2121
+ ( payload : unknown ) => {
2122
+ const perEventExecutionArgs : ValidatedExecutionArgs = {
2123
+ ...validatedExecutionArgs ,
2124
+ rootValue : payload ,
2125
+ } ;
2126
+ return validatedExecutionArgs . perEventExecutor ( perEventExecutionArgs ) ;
2127
+ } ,
2128
+ ( ) => promiseCanceller ?. disconnect ( ) ,
2129
+ ) ;
2140
2130
}
2141
2131
2142
2132
export function executeSubscriptionEvent (
0 commit comments