Skip to content

fields_have_appropriate_selections does not require selections on union types #4351

@gmac

Description

@gmac

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions