Skip to content

Commit 1daa096

Browse files
committed
[Bug Reproduce] Can't use undefined and as enum value
**Extracted from graphql#1267** From graphql#836 it looks like both `undefined` and `NaN` could be used as an enum values: ```js const TestEnum = new GraphQLEnumType({ name: 'TestEnum', values: { UNDEFINED: { value: undefined }, NAN: { value: NaN }, }, }); ``` And run this query: ```graphql { undefined: fieldWithEnumInput(input: UNDEFINED) NaN: fieldWithEnumInput(input: NAN) } ``` It will result in: ```json { "data": { "undefined": null, "NaN": null }, "errors": [ { "message": "Argument \"input\" has invalid value UNDEFINED.", "path": [ "undefined" ] } { "message": "Argument \"input\" has invalid value NAN.", "path": [ "NaN" ] } ] } ```
1 parent 85971a2 commit 1daa096

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/execution/__tests__/variables-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ describe('Execute: Handles inputs', () => {
460460
it('allows custom enum values as inputs', () => {
461461
const result = executeQuery(`
462462
{
463+
undefined: fieldWithEnumInput(input: UNDEFINED)
463464
null: fieldWithEnumInput(input: NULL)
464465
NaN: fieldWithEnumInput(input: NAN)
465466
false: fieldWithEnumInput(input: FALSE)
@@ -470,6 +471,7 @@ describe('Execute: Handles inputs', () => {
470471

471472
expect(result).to.deep.equal({
472473
data: {
474+
undefined: 'undefined',
473475
null: 'null',
474476
NaN: 'NaN',
475477
false: 'false',

0 commit comments

Comments
 (0)