Skip to content

Commit 02d71a0

Browse files
committed
astFromNode does not converts NonNull values to NullValue
1 parent 03a90d6 commit 02d71a0

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/utilities/__tests__/astFromValue-test.js

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
GraphQLString,
2020
GraphQLBoolean,
2121
GraphQLID,
22+
GraphQLNonNull,
2223
} from '../../type';
2324

2425

@@ -149,6 +150,13 @@ describe('astFromValue', () => {
149150
);
150151
});
151152

153+
it('does not converts NonNull values to NullValue', () => {
154+
const NonNullBoolean = new GraphQLNonNull(GraphQLBoolean);
155+
expect(astFromValue(null, NonNullBoolean)).to.deep.equal(
156+
null
157+
);
158+
});
159+
152160
const complexValue = { someArbitrary: 'complexValue' };
153161

154162
const myEnum = new GraphQLEnumType({

src/utilities/astFromValue.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ export function astFromValue(
7171
const _value = value;
7272

7373
if (type instanceof GraphQLNonNull) {
74-
// Note: we're not checking that the result is non-null.
75-
// This function is not responsible for validating the input value.
76-
return astFromValue(_value, type.ofType);
74+
const astValue = astFromValue(_value, type.ofType);
75+
if (astValue && astValue.kind === NULL) {
76+
return null;
77+
}
78+
return astValue;
7779
}
7880

7981
// only explicit null, not undefined, NaN

0 commit comments

Comments
 (0)