Skip to content

A union that's only a member of another union fails to build #866

Open

Description

@oryan-block
type Query {
    results: [Result!]!
}

union Result = Book | Media

union Media = Movie

fails with

No object type found with name 'Media' for union: UnionTypeDefinition{name='Result'...}

SchemaParser#getLeafUnionObjects flattens nested unions, but SchemaClassScanner#getAllObjectTypeMembersOfDiscoveredUnions only skips member unions that are already in the dictionary, and Media isn't since no field returns it. It works once some field returns Media.

The spec only allows object types as union members, so nested unions are a tools-only thing. Not sure if it's worth fixing or if they should be rejected with a clearer error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions