Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions src/execution/execute.js
Original file line number Diff line number Diff line change
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