Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
fix(stitching): do not convert falsy values to null.
Browse files Browse the repository at this point in the history
Closes #10. Renamed resultObject to result to remind code/coders that the result may be a scalrar, not an object, and may be falsy without being equivalent to null.
  • Loading branch information
yaacovCR committed Jul 5, 2019
1 parent 73e42b9 commit 26c5d67
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/stitching/checkResultAndHandleErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export function checkResultAndHandleErrors(

export function handleResult(
info: GraphQLResolveInfo,
resultObject: any,
result: any,
errors: ReadonlyArray<GraphQLError>
): any {
if (!resultObject) {
if (result == null) {
if (errors.length) {
throw relocatedError(
combineErrors(errors),
Expand All @@ -61,10 +61,10 @@ export function handleResult(
const nullableType = getNullableType(info.returnType);

if (isObjectType(nullableType) || isListType(nullableType)) {
annotateWithChildrenErrors(resultObject, errors);
annotateWithChildrenErrors(result, errors);
}

return parseOutputValue(nullableType, resultObject);
return parseOutputValue(nullableType, result);
}

function parseOutputValue(type: GraphQLType, value: any) {
Expand Down

0 comments on commit 26c5d67

Please sign in to comment.