Enum cannot represent value, when querying for defaultValue
See original GitHub issueI’m using ariadne and suddenly started encountering an error from the introspection query issued by GraphQL Playground when I upgraded from ariadne 0.12.0 to 0.13.0.
I’ve boiled the problem down as simply as possible and actually it seems to have nothing to do with ariadne, but instead is a change in behaviour from graphql-core 3.0 -> 3.1.
The following works in graphql-core 3.0, but not in 3.1:
import graphql
import pprint
schema = graphql.build_schema("""
enum Role {
ADMIN
USER
}
type Query {
hello(r: Role = USER): String
}
""")
query = "{__schema{types{name,fields{name,args{name,defaultValue}}}}}"
result = graphql.graphql_sync(schema, query)
pprint.pprint(result)
In graphql-core 3.1, it throws the error: Enum 'Role' cannot represent value: 'USER'
Could someone tell me if I’m doing something wrong? Have I been making an incorrect assumption which errorneously passed in 3.0 and has now been “fixed”? Or is this a regression?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Enum $EnumName cannot represent non-enum value
I am getting this error message when I run my query that seems contradictory. I've followed the enum example in the documentation pretty...
Read more >Using enums as argument default values is broken ... - GitHub
The introspection query which is issued by GraphQL Playground throws an error ... GraphQLError: Enum 'Role' cannot represent value: 'USER'.
Read more >What you need to know about GraphQL enums
The field using an enum type requires an enum reference, so passing the enum value isn't considered valid.
Read more >MySQL 8.0 Reference Manual :: 11.3.5 The ENUM Type
If an ENUM column is declared to permit NULL , the NULL value is a valid value for the column, and the default...
Read more >How to use GraphQL enum and its best practices
The enum class allows us to map enum values to internal values represented by integers (or different strings etc.).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@bnaoki do you still get the error message if you completely remove ariadne from the equation? I took my code snippet above and changed the default value to be non-nullable, and the error goes away with graphql-core 3.1.4.
I think the problem might be in ariadne now. Even after upgrading to graphql-core 3.1.4, I still get the error you’re seeing when I have an enum as a default argument value in my SDL. But I think this is because ariadne does not properly support this case yet. See: https://github.com/mirumee/ariadne/issues/293
For the time being I’ve had to remove these default values from my schema to make ariadne 0.13.0 happy.
Ahh, you’re right. It does seem to be an issue with
ariadne. Thanks for this info!