I am trying to resolve the following (this is the return value of my resolver function, and I am passing it to the resolve
macro):
{:ok,
%{
collection: nil,
errors: %{
recoverable: [
%{
__exception__: true,
__recoverable__: true,
message: %{
color: %{
exterior: ["is invalid"],
interior: ["is invalid"]
}
},
type: :vehicle_invalid
}
],
unrecoverable: []
}
}}
This returns this classic error:
** (Protocol.UndefinedError) protocol String.Chars not implemented for %{color: %{exterior: ["is invalid"], interior: ["is invalid"]}} of type Map. This protocol is implemented for the following type(s): Money, Postgrex.Copy, Postgrex.Query, Floki.Selector.AttributeSelector, Floki.Selector, Floki.Selector.Functional, Floki.Selector.Combinator, Floki.Selector.PseudoClass, Decimal, Float, DateTime, Time, List, Version.Requirement, Atom, Integer, Version, Date, BitString, NaiveDateTime, URI
which I get, it doesn't know how to convert the map to a string, but that leads to my actual question:
I am wondering why the top level errors
map can get parsed fine, but not the nested messages
map, would love some guidance, thanks!
Note: Our pattern is to have Ecto style validation errors come back under our own data, rather than the top level Graph query errors, hence the :ok tuple rather than resolving an :error tuple