Our First Module
In Chapter 5, âMaking a Change with Mutationsâ, we added several resolution functions that all copied an error-handling function we first developed to power the :create_menu_item mutation field. This error-handling function enabled the system to give users feedback about errors that bubble up from the underlying databaseâfrom internal schema-validation problems like missing and badly formatted arguments to database constraint violations.
Letâs take a look at that resolver again:
â | âdefâ create_item(_, %{âinput:â params}, _) âdoâ |
â | âcaseâ Menu.create_item(params) âdoâ |
â | {â:errorâ, changeset} -> |
â | {â:okâ, %{âerrors: ... |
Get Craft GraphQL APIs in Elixir with Absinthe now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.