Skip to content

Commit 266f9fa

Browse files
execute: inline collectAndExecuteSubfields function (#3083)
1 parent 0ebcb2f commit 266f9fa

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

src/execution/execute.js

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,9 @@ function completeObjectValue(
10171017
path: Path,
10181018
result: mixed,
10191019
): PromiseOrValue<ObjMap<mixed>> {
1020+
// Collect sub-fields to execute to complete this value.
1021+
const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes);
1022+
10201023
// If there is an isTypeOf predicate function, call it with the
10211024
// current result. If isTypeOf returns false, then raise an error rather
10221025
// than continuing execution.
@@ -1028,12 +1031,12 @@ function completeObjectValue(
10281031
if (!resolvedIsTypeOf) {
10291032
throw invalidReturnTypeError(returnType, result, fieldNodes);
10301033
}
1031-
return collectAndExecuteSubfields(
1034+
return executeFields(
10321035
exeContext,
10331036
returnType,
1034-
fieldNodes,
1035-
path,
10361037
result,
1038+
path,
1039+
subFieldNodes,
10371040
);
10381041
});
10391042
}
@@ -1043,13 +1046,7 @@ function completeObjectValue(
10431046
}
10441047
}
10451048

1046-
return collectAndExecuteSubfields(
1047-
exeContext,
1048-
returnType,
1049-
fieldNodes,
1050-
path,
1051-
result,
1052-
);
1049+
return executeFields(exeContext, returnType, result, path, subFieldNodes);
10531050
}
10541051

10551052
function invalidReturnTypeError(
@@ -1063,18 +1060,6 @@ function invalidReturnTypeError(
10631060
);
10641061
}
10651062

1066-
function collectAndExecuteSubfields(
1067-
exeContext: ExecutionContext,
1068-
returnType: GraphQLObjectType,
1069-
fieldNodes: $ReadOnlyArray<FieldNode>,
1070-
path: Path,
1071-
result: mixed,
1072-
): PromiseOrValue<ObjMap<mixed>> {
1073-
// Collect sub-fields to execute to complete this value.
1074-
const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes);
1075-
return executeFields(exeContext, returnType, result, path, subFieldNodes);
1076-
}
1077-
10781063
/**
10791064
* A memoized collection of relevant subfields with regard to the return
10801065
* type. Memoizing ensures the subfields are not repeatedly calculated, which

0 commit comments

Comments
 (0)