Resolver Function
Learn how to create a resolver function and how to return data from mutations.
We'll cover the following...
Building the resolver
Let’s build the resolver function. It will grab the :input
argument for us, and then call a general-purpose PlateSlate.Menu.create_item/1
unction that will handle persisting the record:
Press + to interact
def create_item(_, %{input: params}, _) docase Menu.create_item(params) do{:error, _} ->{:error, "Could not create menu item"}{:ok, _} = success ->successendend
Here’s how we’ve implemented ...