Skip to content

Commit

Permalink
execute: inline collectAndExecuteSubfields function (#3083)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 13, 2021
1 parent 0ebcb2f commit 266f9fa
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions src/execution/execute.js
Expand Up @@ -1017,6 +1017,9 @@ function completeObjectValue(
path: Path,
result: mixed,
): PromiseOrValue<ObjMap<mixed>> {
// 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.
Expand All @@ -1028,12 +1031,12 @@ function completeObjectValue(
if (!resolvedIsTypeOf) {
throw invalidReturnTypeError(returnType, result, fieldNodes);
}
return collectAndExecuteSubfields(
return executeFields(
exeContext,
returnType,
fieldNodes,
path,
result,
path,
subFieldNodes,
);
});
}
Expand All @@ -1043,13 +1046,7 @@ function completeObjectValue(
}
}

return collectAndExecuteSubfields(
exeContext,
returnType,
fieldNodes,
path,
result,
);
return executeFields(exeContext, returnType, result, path, subFieldNodes);
}

function invalidReturnTypeError(
Expand All @@ -1063,18 +1060,6 @@ function invalidReturnTypeError(
);
}

function collectAndExecuteSubfields(
exeContext: ExecutionContext,
returnType: GraphQLObjectType,
fieldNodes: $ReadOnlyArray<FieldNode>,
path: Path,
result: mixed,
): PromiseOrValue<ObjMap<mixed>> {
// 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
Expand Down

0 comments on commit 266f9fa

Please sign in to comment.