-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Ability to query interfaces that a union implements #44
Comments
This is not that simple to implement, why don't you use the interface directly instead of the union? interface ClientError {
message: String!
}
type ClientErrorNameAlreadyTaken implements ClientError {
message: String!
}
type ClientErrorNameInvalid implements ClientError {
message: String!
}
type Query {
error: ClientError
} |
So in our case, we'd like to eventually have some error-specific fields as well (the example was rather simplified). So let's say The goal of my second query then, is to fetch common fields from a all types within the union. I'll also let @jasonkuhrt chime in if he wants |
@remorses Because not every operation will return every kind of client error, but we want all client errors to share a base interface so that clients can do a catch-all on the errors of an operation because:
More details on this topic here: https://productionreadygraphql.com/2020-08-01-guide-to-graphql-errors |
Would you be open for a PR from us? |
I will work on this, I already know what to change, i also need to clean up tests because now it's a mess |
Released in 2.4.0 |
@remorses Just tried this out, works exactly as expected! Thanks so much for getting this out so incredibly quickly! |
We're using
genql
's typings on an upcoming app and its been working really well! It fits right in, and typed queries and mutations are awesome!There's one area where type support is limited though, and that has to do with interfaces and unions.
When querying against a resource that returns a union, you should also be able to query interfaces that the union's types implement. Currently, it is only possible to query individual types within the union.
Perhaps an example will make this clearer.
So assume this (part of) GraphQL schema
Here, this query is currently possible:
as
However, the following is also a valid query in GraphQL that
genql
disallows:It'd be awesome if
genql
could let me query it this way:If I'm being unclear, please let me know!
I'm more than happy to send a PR your way to support this if you like :)
The text was updated successfully, but these errors were encountered: