Skip to content

Default enum values ignored when parsing a schema #111

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

Closed
charmasaur opened this issue Oct 19, 2020 · 2 comments
Closed

Default enum values ignored when parsing a schema #111

charmasaur opened this issue Oct 19, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@charmasaur
Copy link
Contributor

The following code:

import graphql
schema = graphql.build_ast_schema(graphql.parse("""
enum Enum {
  DEFAULT
}
input Input {
  enumField: Enum = DEFAULT
}"""))
print(schema.type_map['Input'].fields['enumField'].default_value)

produces None.

I guess I'm not really sure what it should be returning, but I think "DEFAULT" would be more appropriate than None.

@Cito
Copy link
Member

Cito commented Oct 20, 2020

Thanks for reporting. It boils down to this.

>>> schema = graphql.build_ast_schema(graphql.parse("enum Enum { DEFAULT }"))
>>> print(schema.type_map['Enum'].values['DEFAULT'].value)
None

So, it looks like the internal values of the enum types created from SDL are set to None.

I agree they should better be the same as the names.

@Cito Cito self-assigned this Oct 20, 2020
@Cito Cito added the bug Something isn't working label Oct 20, 2020
@Cito Cito closed this as completed in 2a1953f Oct 20, 2020
@charmasaur
Copy link
Contributor Author

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants