@@ -200,7 +200,7 @@ export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
200
200
return { errors : exeContext } ;
201
201
}
202
202
203
- return executeQueryOrMutation ( exeContext , exeContext . operation , rootValue ) ;
203
+ return executeQueryOrMutation ( exeContext ) ;
204
204
}
205
205
206
206
/**
@@ -225,14 +225,8 @@ export function executeSync(args: ExecutionArgs): ExecutionResult {
225
225
*/
226
226
function executeQueryOrMutation (
227
227
exeContext : ExecutionContext ,
228
- operation : OperationDefinitionNode ,
229
- rootValue : unknown ,
230
228
) : PromiseOrValue < ExecutionResult > {
231
- const data = executeQueryOrMutationRootFields (
232
- exeContext ,
233
- operation ,
234
- rootValue ,
235
- ) ;
229
+ const data = executeQueryOrMutationRootFields ( exeContext ) ;
236
230
237
231
if ( isPromise ( data ) ) {
238
232
return data . then ( ( resolved ) => buildResponse ( exeContext , resolved ) ) ;
@@ -366,14 +360,14 @@ export function buildExecutionContext(
366
360
* */
367
361
function executeQueryOrMutationRootFields (
368
362
exeContext : ExecutionContext ,
369
- operation : OperationDefinitionNode ,
370
- rootValue : unknown ,
371
363
) : PromiseOrValue < ObjMap < unknown > | null > {
372
- const type = getOperationRootType ( exeContext . schema , operation ) ;
364
+ const { schema, fragments, rootValue, operation, variableValues } =
365
+ exeContext ;
366
+ const type = getOperationRootType ( schema , operation ) ;
373
367
const fields = collectFields (
374
- exeContext . schema ,
375
- exeContext . fragments ,
376
- exeContext . variableValues ,
368
+ schema ,
369
+ fragments ,
370
+ variableValues ,
377
371
type ,
378
372
operation . selectionSet ,
379
373
) ;
@@ -568,6 +562,9 @@ export function buildResolveInfo(
568
562
parentType : GraphQLObjectType ,
569
563
path : Path ,
570
564
) : GraphQLResolveInfo {
565
+ const { schema, fragments, rootValue, operation, variableValues } =
566
+ exeContext ;
567
+
571
568
// The resolve function's optional fourth argument is a collection of
572
569
// information about the current execution state.
573
570
return {
@@ -576,11 +573,11 @@ export function buildResolveInfo(
576
573
returnType : fieldDef . type ,
577
574
parentType,
578
575
path,
579
- schema : exeContext . schema ,
580
- fragments : exeContext . fragments ,
581
- rootValue : exeContext . rootValue ,
582
- operation : exeContext . operation ,
583
- variableValues : exeContext . variableValues ,
576
+ schema,
577
+ fragments,
578
+ rootValue,
579
+ operation,
580
+ variableValues,
584
581
} ;
585
582
}
586
583
@@ -1078,17 +1075,18 @@ export async function executeSubscription(
1078
1075
}
1079
1076
1080
1077
// For each payload yielded from a subscription, map it over the normal
1081
- // GraphQL `execute` function, with `payload` as the rootValue.
1078
+ // GraphQL `execute` function, with `payload` as the rootValue and with
1079
+ // an empty set of errors.
1082
1080
// This implements the "MapSourceToResponseEvent" algorithm described in
1083
1081
// the GraphQL specification. The `execute` function provides the
1084
1082
// "ExecuteSubscriptionEvent" algorithm, as it is nearly identical to the
1085
1083
// "ExecuteQuery" algorithm, for which `execute` is also used.
1086
1084
const mapSourceToResponse = ( payload : unknown ) =>
1087
- executeQueryOrMutation (
1088
- { ...exeContext , errors : [ ] } ,
1089
- exeContext . operation ,
1090
- payload ,
1091
- ) ;
1085
+ executeQueryOrMutation ( {
1086
+ ...exeContext ,
1087
+ rootValue : payload ,
1088
+ errors : [ ] ,
1089
+ } ) ;
1092
1090
1093
1091
// Map every source value to a ExecutionResult value as described above.
1094
1092
return mapAsyncIterator ( resultOrStream , mapSourceToResponse ) ;
0 commit comments