-
Notifications
You must be signed in to change notification settings - Fork 536
The error formatter is dropping custom fields #444
Comments
@justinmchase It should be either: throw Object.assign(new Error('example'), { extensions: {code: 'E_EXAMPLE' }}) Or you should use |
Perfect, both worked for me, thanks! For the record in both cases throw Object.assign(new Error('example'), { A; 'a', extensions: { B: 'b' } })
// ...
formatError: ({ originalError: { A }, extensions: { B } }) => ({
A,
B
}) |
@justinmchase Note that latest version of GraphQL spec changed things a bit:
In |
Works for me. Here's how i did for those who are wondering. I created my own custom error:
Threw the error in the resolver and then referenced my additional property like so:
|
I am throwing an error in my handler but later in the formatError function the error object is of a different type and it has dropped all of my custom fields.
How can I throw an error which has fields that persist into the error formatter?
The text was updated successfully, but these errors were encountered: