You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In GraphQL, you should be able to spread an interface or union against a union, as long as there's some type that satisfies both. For example:
interface Error {
message: String
}
type ErrorA implements Error {
message: String
}
type ErrorB implements Error {
message: String
}
type Success {
updated: Int
}
union Result = Success | ErrorA | ErrorB
type Mutation {
doIt: Result
}
mutation M {
doIt {
... on Error {
message
}
... on Success {
updated
}
}
}
This mutation is a valid operation, but graphql-client will block it with error: Failed to generate GraphQLQuery impl: The spread Result... on Error is not valid.
This is unfortunate as it's a nice pattern for mutations to return a union that allows a bunch of different error types, but to let a client process all errors together if they want.
(I ran into this while debugging an issue with https://github.com/apollographql/rover but I'm not personally a strong Rust developer so I wasn't able to quickly turn this into a standalone test case — if you can show the proper part of the repo to do so, I'm happy to do so.)
The text was updated successfully, but these errors were encountered:
In GraphQL, you should be able to spread an interface or union against a union, as long as there's some type that satisfies both. For example:
This mutation is a valid operation, but
graphql-client
will block it witherror: Failed to generate GraphQLQuery impl: The spread Result... on Error is not valid.
This is unfortunate as it's a nice pattern for mutations to return a union that allows a bunch of different error types, but to let a client process all errors together if they want.
(I ran into this while debugging an issue with https://github.com/apollographql/rover but I'm not personally a strong Rust developer so I wasn't able to quickly turn this into a standalone test case — if you can show the proper part of the repo to do so, I'm happy to do so.)
The text was updated successfully, but these errors were encountered: