I have the following model
type Duck {
category: Baz
}
type Foo {
size: FooSize
}
type Bar {
size: BarSize
}
union Baz = Foo | Bar
The following query throws an error Validation error of type FieldsConflict: size: they return differing types FooSize and BarSize @ 'duck/category' (it's an intended behaviour as stated here : https://github.com/graphql/graphql-js/issues/53)
{
duck {
category {
... on Foo {
size
}
... on Bar {
size
}
}
}
}
Aliases on size would make the query work, but I can't use them here, because the query results will be passed back to another API which expect Duck.category to have a key named exactly size.
Is there any workaround, or schema refactoring I could use here to get this working ?
At a high level, you can only do three things to resolve that error:
size field is the same type for both types.If you need to pass the response to another API, the easiest thing would be to use aliases and then transform the response client-side before sending it to the API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With