Skip to content
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

Allow for nullish values when defining enums #836

Merged
merged 1 commit into from
Apr 29, 2017
Merged

Allow for nullish values when defining enums #836

merged 1 commit into from
Apr 29, 2017

Conversation

leebyron
Copy link
Contributor

Fixes #832

@leebyron leebyron merged commit 5b06511 into master Apr 29, 2017
@leebyron leebyron deleted the fix-832 branch April 29, 2017 02:04
IvanGoncharov added a commit to IvanGoncharov/graphql-js that referenced this pull request Jun 5, 2018
**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" ]
    }
  ]
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants