This repository was archived by the owner on Mar 20, 2023. It is now read-only.
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
The error formatter is dropping custom fields #444
Closed
Description
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.
throw Object.assign(new Error('example'), { code: 'E_EXAMPLE' })
app.use('/api', graphql({
schema,
rootValue: root
graphiql: true,
formatError: error => console.log(error) || ({
message: error.message,
code: error.code, // null, why?
locations: error.locations,
stack: error.stack ? error.stack.split('\n') : [],
path: error.path
})
}))
How can I throw an error which has fields that persist into the error formatter?
Metadata
Metadata
Assignees
Labels
No labels