https://serverless-stack.com/ logo
#random
Title
# random
t

thdxr

01/08/2022, 10:24 PM
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

Omi Chowdhury

01/09/2022, 11:08 AM
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

thdxr

01/09/2022, 2:20 PM
Thats an issue even with normal errors right since gql always returns 200s
o

Omi Chowdhury

01/09/2022, 2:22 PM
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

thdxr

01/09/2022, 3:21 PM
Also aren't your customers using generated client libraries? Does that help at all?
o

Omi Chowdhury

01/09/2022, 3:22 PM
Most are, but not everyone makes sure to exhaustively check the types, or even uses a typed language