Skip to content

Pass down context info to serialize method of leaf nodes #2268

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

Closed
Closed
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
6 changes: 3 additions & 3 deletions src/execution/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ function completeValue(
// If field type is a leaf type, Scalar or Enum, serialize to a valid value,
// returning null if serialization is not possible.
if (isLeafType(returnType)) {
return completeLeafValue(returnType, result);
return completeLeafValue(returnType, result, fieldNodes, info);
}

// If field type is an abstract type, Interface or Union, determine the
Expand Down Expand Up @@ -935,8 +935,8 @@ function completeListValue(
* Complete a Scalar or Enum by serializing to a valid value, returning
* null if serialization is not possible.
*/
function completeLeafValue(returnType: GraphQLLeafType, result: mixed): mixed {
const serializedResult = returnType.serialize(result);
function completeLeafValue(returnType: GraphQLLeafType, result: mixed, fieldNodes: $ReadOnlyArray<FieldNode>, info: GraphQLResolveInfo): mixed {
const serializedResult = returnType.serialize(result, fieldNodes, info);
if (isInvalid(serializedResult)) {
throw new Error(
`Expected a value of type "${inspect(returnType)}" but ` +
Expand Down