Tuples
Explore how tuples are used in GraphQL mutation resolvers to represent success and error outcomes. Learn to extract and format error details from Ecto changesets for clear API responses. Understand how to improve error handling in Absinthe with detailed feedback for users.
We'll cover the following...
We'll cover the following...
Using tuples
Field resolver functions return tuple values to indicate their result:
The return value for PlateSlate.Menu.create_item/1 is a tuple and we do a bit of post-processing on the value to return a nicely formatted value for Absinthe to include in the response. Successful values are returned untouched, but error values are replaced with a generic message, “Could not create menu item.” ...