|
|
|
|
|
by satvikpendem
1098 days ago
|
|
GraphQL has strongly typed errors unlike REST. It is very akin to the Result type in many languages in that you are forced to handle errors even when writing the query, and the query will simply not compile if you don't. For example, the Pothos library implements this pattern automatically: type Error {
message: String!
}
type Query {
hello(name: String!): QueryHelloResult
}
union QueryHelloResult = Error | QueryHelloSuccess
type QueryHelloSuccess {
data: String!
}
This field can be queried using fragments like: query {
hello(name: "World") {
__typename
... on Error {
message
}
... on QueryHelloSuccess {
data
}
}
}
https://pothos-graphql.dev/docs/plugins/errors |
|
If someone has solved the asshole corporate middle box problem using GQL, that’s really good news.