I’m playing with elixir and graphql and I want to return my model for a given argument, in this case, it will be ean_code
so
def get_product(%{ean_code: ean_code}) do
item =
Item
|> where([t], t.ean_code == ^ean_code)
|> Repo.all()
{:ok, item}
end
get_product should return all if
ean_code` match the given value, this is my mutation
field :item, type: :string do
arg :ean_code, non_null(:string)
resolve fn _, args, _ ->
Product.get_product(args)
end
end
and error is
To be converted to a string, a list must either be empty or only
contain the following elements:
* strings
* integers representing Unicode code points
* a list containing one of these three elements
Please check the given list or call inspect/1 to get the list representation, got:
[%Scan.Product.Schema.Item{__meta__: #Ecto.Schema.Metadata<:loaded, "items">, br
The error is self-explanatory but I’m a bit confused on how to solve it, so can someone help me understand how can I convert this, thanks.