Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execute: inline collectAndExecuteSubfields function #3083

Merged
merged 1 commit into from May 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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