Using Ecto v2.2.6, Phoenix 1.3
I have Absinthe installed on my Phoenix instance and am able to run queries on it with no trouble, but I cannot get mutations to work.
I have absinthe installed thusly in mix.exs:
...
{:absinthe, "~> 1.3.0-rc.0"},
{:absinthe_plug, "~> 1.3.0-rc.0"},
{:absinthe_ecto, git: "https://github.com/absinthe-graphql/absinthe_ecto.git"},
...
Then I created a simple object to test. (Ran migration, added route, did not modify schema)
mix phx.gen.json Content Thing things name:string
Tested Repo.insert! from iex. Works fine.
I added the Thing to types.ex:
defmodule MyApp.Schema.Types do
use Absinthe.Schema.Notation
use Absinthe.Ecto, repo: MyApp.Repo
object :thing do
field :id, :id
field :name, :string
end
end
Now the schema. I put Thing into a query field and I can see it just fine. The mutation then goes in:
mutation do
field :create_thing, :thing do
arg :name, non_null(:string)
resolve fn(%{name: name}, _context) ->
IO.puts "TESTING"
thing = MyApp.Repo.insert!(%MyApp.Content.Thing{ name: name })
{:ok, thing}
end
end
end
Then I type into graphiql:
mutation {
createThing(name: "test") {
id
}
}
…and the iex console says:
[info] GET /graphiql
[debug] ABSINTHE schema=nil variables=%{}
---
mutation {
createThing(name: "test") {
id
}
}
---
[info] Sent 405 in 325µs
…and my graphiql window tells me SyntaxError: Unexpected token C in JSON at position 0
Any ideas on how to troubleshoot this?