From 266f9fa7317b8ac1828fac7c36807badfff393b3 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 13 May 2021 15:20:48 +0300 Subject: [PATCH] execute: inline collectAndExecuteSubfields function (#3083) --- src/execution/execute.js | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/execution/execute.js b/src/execution/execute.js index 4486e95eea..664bc13308 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -1017,6 +1017,9 @@ function completeObjectValue( path: Path, result: mixed, ): PromiseOrValue> { + // Collect sub-fields to execute to complete this value. + const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes); + // If there is an isTypeOf predicate function, call it with the // current result. If isTypeOf returns false, then raise an error rather // than continuing execution. @@ -1028,12 +1031,12 @@ function completeObjectValue( if (!resolvedIsTypeOf) { throw invalidReturnTypeError(returnType, result, fieldNodes); } - return collectAndExecuteSubfields( + return executeFields( exeContext, returnType, - fieldNodes, - path, result, + path, + subFieldNodes, ); }); } @@ -1043,13 +1046,7 @@ function completeObjectValue( } } - return collectAndExecuteSubfields( - exeContext, - returnType, - fieldNodes, - path, - result, - ); + return executeFields(exeContext, returnType, result, path, subFieldNodes); } function invalidReturnTypeError( @@ -1063,18 +1060,6 @@ function invalidReturnTypeError( ); } -function collectAndExecuteSubfields( - exeContext: ExecutionContext, - returnType: GraphQLObjectType, - fieldNodes: $ReadOnlyArray, - path: Path, - result: mixed, -): PromiseOrValue> { - // Collect sub-fields to execute to complete this value. - const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes); - return executeFields(exeContext, returnType, result, path, subFieldNodes); -} - /** * A memoized collection of relevant subfields with regard to the return * type. Memoizing ensures the subfields are not repeatedly calculated, which