I've got an issue on my project and I can't find any solution on the internet. Here is the situation.
- I've an Union (
DataResult) of 2 types (Teaser&Program) - I've a
Zonetype with adatafield (an arrayDataResult) Teaser&Programhave the sametitlefield with a different type (StringvsString!)
Here is parts from Zone, Teaser and Program schemas:
type Program {
title: String
}
type Teaser {
title: String!
}
union DataResult = Teaser | Program
type Zone {
(...)
data: [DataResult!]
}
When I tried to query zone data as described in the query part below, I've got an error from GraphQL.
zones {
...zoneFieldsWithoutData
data {
... on Program {
...programFields
}
... on Teaser {
...teaserFields
}
}
}
Here is the error:
Error: GraphQL error: Fields \"title\" conflict because they return conflicting types String and String!. Use different aliases on the fields to fetch both if this was intentional
I can't use an alias because the specs needs the same attribute name for all "DataResult" entities. What can I do ?
Moreover, even if I set the same Type for title, I've a lot of warning about "missing fields" in the console....
PS: I use Vanilla Apollo as GraphQL client (on the server side)
{ data { title: 'Title 1', title: 'Title 2' }}which doesn't make a lot of sense since you might not differentiate between what title belongs to Program or Teaser and that's why it insists on using aliases. - kimobrian254