graphql-ruby
graphql-ruby copied to clipboard
`fields_have_appropriate_selections` does not require selections on union types
Describe the bug
The fields_have_appropriate_selections
validation presently allows the following selection:
query { myUnion }
With myUnion
being a union type, this query returns the following payload:
{ "data": { "myUnion": {} } }
The spec would require a union type to make a selection.
Cause
The issue occurs here: https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb#L34
The cause of the issue is that the fields?
check omits union types. To fix this validation, the check should use composite?
instead of fields?
.
Steps to resolution
Unfortunately this is a breaking change as sources that used to validate will now fail. Need to:
- Fix the relevant check.
- Hook breaking behavior to a schema-level setting for spec-compliance. Should also include https://github.com/rmosolgo/graphql-ruby/issues/4403