Return Errors

Learn an alternate way to return errors in GraphQL.

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:

Press + to interact
mutation do
field :create_menu_item, :menu_item do
#<<content>>
end
end

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 ...