Querying same field w/ and w/o attributes for different union types results in error
See original GitHub issueQuery:
{
curatedList {
...on Program {
title(lang: "fi")
}
...on Article {
title
}
}
}
Error:
Fields title conflict because they have differing arguments.
Should it really work like that, or is this a bug?
Article and Program are both members of union type Content
Issue Analytics
- State:
- Created 8 years ago
- Reactions:7
- Comments:23 (8 by maintainers)
Top Results From Across the Web
SQL UNION overview, usage and examples
This article provides overview of the SQL UNION operator, along with examples and explore some common questions like the differences between ...
Read more >sql - UNION ALL two SELECTs with different column types
If you want to use union all columns in every query need to have the same type. C3 must be converteted to varchar...
Read more >Handling GraphQL errors like a champ with unions and ...
Error handling can be frustrating in GraphQL. This post shows you how to use unions and interfaces to handle errors in a more...
Read more >Customizing the behavior of cached fields - Apollo GraphQL
You can customize how a particular field in your Apollo Client cache is read and written. To do so, you define a field...
Read more >Use a union query to combine multiple queries into a single ...
Get a combined view of multiple select queries with a union query. ... compatible data types with fields in the same position in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is so bad, I have several TS interfaces and I expect my results to match those interfaces, if I start aliasing the unions then they won’t match and I’m going to have to convert the results to match the TS interfaces.
I’m going to use just a plain
JSONResolver
for the conflicting fields. Graphql should support unions for scalars, and if that goes against the spec, then the spec is probably wrong and should be fixed. There should be at least a way to relax this or provide a solution that does not imply aliasing or having to interpret the results after in any way.Union types are ambiguous by definition, you either support them or you don’t.
I think we could probably improve this if two fields are known to never “merge”. In this case, the two types are Object types and in no condition would both “title” fields be queried for the same object.
We should be a bit smarter about this (likely common) case