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

fields_have_appropriate_selections does not require selections on union types #4351

Open
gmac opened this issue Feb 17, 2023 · 0 comments
Open
Milestone

Comments

@gmac
Copy link
Contributor

gmac commented Feb 17, 2023

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants