New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to query fields of union type even if all types in union are object types #22
Comments
Found the solution — |
This is intentional, when querying against a Union you must narrow the type by using a fragment.
This ensures that your query will be resilient to the evolution of the type schema over time. When this client has shipped, and you introduce a new type into your If |
Can you please write an example? I get
|
It would be great to be able to opt out of this intentional safety check. In some apps where e.g. the same developer or team works the full stack then the better tradeoff for them might be that they can select on common fields of the union type. Yes it will crash if the union is extended by the server, but the queries are flatter/easier to make. Assuming there is only one right answer here for all apps and teams is not ideal IMO. |
Looks like if all types in a union implement an interface, containing the common fields, you can then query those common fields by narrowing to that interface.
Then you can query a field of type
|
The text was updated successfully, but these errors were encountered: