Skip to content
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
@justinmchase

Description

@justinmchase

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions