-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
GraphQL gem allows empty object types (in violation of GraphQL spec) #4509
Comments
Thanks for the detailed report -- I agree that it should work like you described but instead, I seem to have a spec with the opposite: 🤦 I'm open to correcting this but, out of curiousity, how did it become a problem for you? |
I work on a framework that leverages the GraphQL gem as part of providing a GraphQL interface. A new user of the framework ran into a situation where autocomplete wasn't working in GraphiQL and when he asked us to look into it we noticed GraphiQL had given him this error: {
"errors": [
"Type SomeType must define one or more fields."
]
} He had defined |
Also https://the-guild.dev/graphql/codegen fails on empty object types with cryptic errors |
Describe the bug
According to the GraphQL spec:
However, the GraphQL gem appears to treat object types that have no fields as valid.
Versions
graphql
version: 2.0.22rails
(or other framework): N/Aother applicable versions (
graphql-batch
, etc): N/AGraphQL schema
GraphQL query
N/A
Steps to reproduce
Create a
graphql_gem_bug_no_fields.rb
file with these contents:Run the file.
Expected behavior
I expect the GraphQL gem's schema validation (which happens when you round-trip an SDL string through the gem's parser and dumper) to fail and indicate that
EmptyObject
isn't valid.Actual behavior
The GraphQL gem treats this schema as valid valid, resulting in this output:
Additional context
#1923 was previously reported for this issue and was apparently resolved by #2462. So looks like a regression? Not sure when it crept back in.
The text was updated successfully, but these errors were encountered: