When a function is specified in resolve and pattern matching is used, if the matching fails an ugly missing method exception is thrown instead of an helpful error message. Since user input can cause this to fail, a friendly validation error should be given instead.
For example:
This is the relevant schema definition:
%ObjectType{
name: "Mutation",
description: "Root object for performing data mutations",
fields: %{
set_rail_preferences: %{
description: "Updates the rail preferences for a user.",
args: Orchestration.Schema.User.RailPreferences.set_rail_preferences_args,
type: Orchestration.Schema.User.RailPreferences.type,
resolve: fn(_, args = %{id: id}, _) ->
case Orchestration.Data.set_user_rail_preferences(id, args) do
{:ok, user} -> user.preferences.rail
:empty -> nil
end
end
}
}
}
When a function is specified in resolve and pattern matching is used, if the matching fails an ugly missing method exception is thrown instead of an helpful error message. Since user input can cause this to fail, a friendly validation error should be given instead.
For example:
This is the relevant schema definition:
Here is the query document
error message: