graphql-crystal
graphql-crystal copied to clipboard
Allow for customized/templated error hash creation
Hello. Maybe i missed it in the documentation, is there a way to customise error adding fields?
I don't understand what you mean. Whenever a resolve method raises an error the resolved field is set to nil
and an error is added to the response with the message of the raise
.
i will try to be more explicit. some people are customizing error fields, for example: https://medium.com/@tarkus/validation-and-user-errors-in-graphql-mutations-39ca79cd00bf so i was wondering if this kind of thing could be accomplished
This is an interesting feature which is unavailable in the current implementation as it only tracks Errors with a path and a message in the form of a Tuple alias Error = { message: String, path: Array(String|Int32) }
. This architecture could be changed to track a path and an Exception
(which really could be any user defined subclass of Exception
) and then provide functionality for a user defined callback to render the array of errors into the a hash of the desired the form. I don't know what priority to give to such a feature..
For earlier I apologize I do not know English exceptions slower it is better to use a class or format: GraphQL::Error/GraphQL::ResponseError or {:error, data} aka Elixir