Hey,
I’ve created a Absinthe schema that is working. Just for fun I want to try to integrate and learn Absinthe.Phoenix.Controller
. So that I can reuse the same schema in a “classic” controller solution.
I’ve started from the auto-generate code that I get from this
mix phx.gen.html Todos TodoList todo_lists name:string
index
as easy to implement by just following the documentation.
However, from create
I got a little stuck.
Here is my stripped controller.
defmodule BackendWeb.TodoListController do
use BackendWeb, :controller
use Absinthe.Phoenix.Controller, schema: BackendWeb.Schema, action: [mode: :internal]
@graphql """
mutation CreateTodoList($name: String!) {
create_todo_list(name: $name)
}
"""
def create(conn, result) do
# ...
end
end
When I press the button from http://localhost:4000/todo_lists/new
I get
Parameters: %{"_csrf_token" => "..", "todo_list" => %{"name" => "Have fun"}}
I think the mutation needs a %{name: "Have fun"}
. Which means that I need to unpack the incoming request body.
Which is the correct way to massage the incoming data from the form so it fits with the GraphQL query. I want to ask before I try to hack my own solution.
Any help is greatly appreciated.