Skip to content

Commit

Permalink
Allow graphql to pass through null values instead of ignoring them
Browse files Browse the repository at this point in the history
  • Loading branch information
lprhodes committed Dec 21, 2015
1 parent a6bcc75 commit c2a169d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/execution/values.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function coerceValue(type: GraphQLInputType, value: any): any {
return coerceValue(nullableType, value);
}

if (isNullish(value)) {
if (value === undefined) {
return null;
}

Expand All @@ -148,10 +148,9 @@ function coerceValue(type: GraphQLInputType, value: any): any {
return Object.keys(fields).reduce((obj, fieldName) => {
var field = fields[fieldName];
var fieldValue = coerceValue(field.type, value[fieldName]);
if (isNullish(fieldValue)) {
if (fieldValue === undefined) {
fieldValue = field.defaultValue;
}
if (!isNullish(fieldValue)) {
} else {
obj[fieldName] = fieldValue;
}
return obj;
Expand All @@ -162,6 +161,10 @@ function coerceValue(type: GraphQLInputType, value: any): any {
type instanceof GraphQLScalarType || type instanceof GraphQLEnumType,
'Must be input type'
);

if (value === null) {
return null;
}

var parsed = type.parseValue(value);
if (!isNullish(parsed)) {
Expand Down

0 comments on commit c2a169d

Please sign in to comment.