Return Errors
Explore how to represent errors as structured data in GraphQL mutations. Learn to define and return error types within mutation results, update resolvers and tests to handle errors gracefully, and improve client feedback by associating errors with specific mutation outcomes.
We'll cover the following...
We'll cover the following...
Errors as data
To support introspection and better integration with clients, we model our errors as normal data and fully define our errors’ structure as normal types.
If you recall, the mutation field we created earlier returned a :menu_item:
If we represent the relationship between the resulting GraphQL types and fields in a diagram, this is what it would look like:
We would need to expand this modeling a bit to make room for error types. What if, ...