express-graphql icon indicating copy to clipboard operation
express-graphql copied to clipboard

How to add a semantic error code after resolver processing ?

Open devniel opened this issue 7 years ago • 1 comments

Hello,

My goal is simple, I'm currently getting this errors together with data, it seems that they are schema validation errors:

Error: Expected a value of type "ExampleType" but received: exampleValue

And I want to add a custom code to this error (e.g. IGNORE_THIS_ERROR), something related to the Type or even the parent schema, so my client could decide if attend or not this error and consider the data results.

formatError returns the original error, but if I want to customize it in there I assume that I will need to parse the message or path looking for keywords to have an idea of the error returned and based on that assign a code. Is there a way to add metadata to these errors before, maybe in the Type or schema definition ?

Thanks

devniel avatar Nov 30 '18 17:11 devniel

Related https://github.com/facebook/graphql/issues/513

devniel avatar Dec 01 '18 00:12 devniel