Description
Is your feature request related to a problem? Please describe.
When 2 subtypes of the same union type share a field but with a different value type, it's possible to run into query-time errors like below if the client doesn't alias the field with conflicting value types:
Minimal reproducible setup where a Book
is either a Novel
or a Poem
but their id
field is Drn
and Int
respectively.
Sample schema
type Drn {
country: String
id: String
}
type Poem {
id: Int
title: String
author: String
}
type Novel {
id: Drn
title: String
author: String
}
union Book = Poem | Novel
type Query {
books: [Book]
}
Describe the solution you'd like
Creating such scenario in a schema isn't forbidden per se but it would be nice to have the option of enforcing a linting rule preventing it in the first place. The rule would suggest renaming the field(s) in the conflicting subtype(s).
Describe alternatives you've considered
apollographql/eslint-plugin-graphql
but the tool is also missing a rule for this scenario.
Additional context
–