graphql / express-graphql

Create a GraphQL HTTP server with Express.
MIT License
6.34k stars 538 forks source link

Allow custom handling of runtime query errors #780

Open MatthiasKunnen opened 2 years ago

MatthiasKunnen commented 2 years ago

Closes #427. Closes #808.

Why
When runtime errors occur, tracing and logging is paramount to discern between incorrect user input or a faulty backend/frontend. To this end, tracing info can be added to response headers in order for proxies/frontends to log this error and update metrics.

Without this PR, achieving this goal is only possible using dirty solutions such as hijackresponse since express-graphql finalizes the response which prevents later middleware from enhancing it.

linux-foundation-easycla[bot] commented 2 years ago

CLA Signed

The committers are authorized under a signed CLA.

justinmchase commented 2 years ago

I am strongly in favor of this, I definitely need to be able to customize the error code.

MatthiasKunnen commented 2 years ago

Also closes #808

mihairadulescu commented 1 year ago

What can we do to fix this? and have it in production ? Is there anything we can do to allow GraphQL specs 200 status code for error returning? This is fucking all clients , especially apollo client you cannot read body from the response !

saihaj commented 1 year ago

This package is deprecated. You can read more here https://github.com/graphql/express-graphql/pull/817