diff --git a/src/execution/execute.ts b/src/execution/execute.ts index be0323ca76..bcebc879ff 100644 --- a/src/execution/execute.ts +++ b/src/execution/execute.ts @@ -186,8 +186,7 @@ export function execute(args: ExecutionArgs): PromiseOrValue { // at which point we still log the error and null the parent field, which // in this case is the entire response. try { - const { operation } = exeContext; - const result = executeOperation(exeContext, operation); + const result = executeOperation(exeContext); if (isPromise(result)) { return result.then( (data) => buildResponse(data, exeContext.errors), @@ -325,9 +324,10 @@ export function buildExecutionContext( */ function executeOperation( exeContext: ExecutionContext, - operation: OperationDefinitionNode, ): PromiseOrValue> { - const rootType = exeContext.schema.getRootType(operation.operation); + const { operation, schema, fragments, variableValues, rootValue } = + exeContext; + const rootType = schema.getRootType(operation.operation); if (rootType == null) { throw new GraphQLError( `Schema is not configured to execute ${operation.operation} operation.`, @@ -336,16 +336,14 @@ function executeOperation( } const rootFields = collectFields( - exeContext.schema, - exeContext.fragments, - exeContext.variableValues, + schema, + fragments, + variableValues, rootType, operation.selectionSet, ); const path = undefined; - const { rootValue } = exeContext; - switch (operation.operation) { case OperationTypeNode.QUERY: return executeFields(exeContext, rootType, rootValue, path, rootFields);