I realize this might be a stupid question, but I can’t see where my mistake is.
I want to create a GraphQL mutation with absinthe that receives a list of parameteres, creates an object from each of the elements of the list, and then returns a list with the data for the created objects.
In my schema, I have something similar to:
field :create_cars, list_of(:car) do
arg :params, list_of(:car_params)
resolve &Resolvers.Cars.create/3
end
Where :car
is previously defined as an object, such as:
object :car do
field :colour, :string
field :origin, :string
field :id, :integer
...
end
And :car_params
is defined as an input_object:
input_object :car_params do
field :colour, :string
field :origin, :string
...
end
In the Cars
resolver, I have so far a function def create(_root, %{params: params}, _info) do ...
where for the moment I just want to print the params for debugging. I know that the resolver should return {:ok, any()}
so I added a sample response so that it won’t raise an exception. The problem is the mutation doesn’t reach the resolver at all and I think it there is something wrong with my definitions somewhere. My testing in GraphiQL just returns an empty string ""
, but I think that is because Cowboy returns 431 maybe because GraphQL returns an error that is too large (might be wrong here as well).
Am I trying to do something that is not idiomatic? I don’t think this should be a really strange case, though.
Edit:
I forgot to mention the mutation I’m testing with looks like this:
mutation { createCars(params: [
{ colour: "red", origin: "Japan" },
{ colour: "blue", origin: "Germany"}
]) { id } }