Those of you familiar with GQL - how are you handl...
# random
t
Those of you familiar with GQL - how are you handling errors? I see some use error union types on results. It's cool it makes things typesafe but I'm wondering if there are any downsides?
o
I use union types for errors - but only on mutation results not normal queries. One challenge we had with customers is that if a mutation fails, they still get back a 200 response - because an error type is a valid response. So we’ve had cases were people weren’t checking the response and assumed that a 200 OK meant the mutation worked - which I don’t think is a bad assumption. We have an item on our backlog to look into returning 400/500s based on the query result
t
Thats an issue even with normal errors right since gql always returns 200s
o
yeah, unless something goes wrong in the graphql server itself
This seems to be the way to solve it (mostly posting for my future self): https://github.com/apollographql/apollo-server/issues/5288#issuecomment-996928084
t
Also aren't your customers using generated client libraries? Does that help at all?
o
Most are, but not everyone makes sure to exhaustively check the types, or even uses a typed language