March 2018
Intermediate to advanced
304 pages
6h 59m
English
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: transform_errors(changeset)}} |
| | {:ok, menu_item} ... |
Read now
Unlock full access