Skip to content

Incorrect query requirement for union types #682

Description

@stuebingerb

While analyzing #667 I came across UnionsSpecificationTest#a union type should require a selection for all potential types that requires selections for every possible union type:

@Test
fun `a union type should require a selection for all potential types`() {
    expectRequestError<ValidationException>("Missing selection set for type 'Scenario'") {
        testedSchema.executeBlocking(
            """{
            actors {
                name
                favourite {
                    ... on Actor { __typename }
                    ... on Director { name, age }
                }
            }
        }""".trimIndent()
        )
    }
}

However, that requirement doesn't actually seem to be backed by the spec. I wasn't able to find anything related, and the example on https://graphql.com/learn/interfaces-and-unions/#querying-with-unions also executes fine with selections for only a subset of potential types. It also doesn't seem like a similar requirement has been implemented for interfaces in KGraphQL.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions