Open remonke opened 1 year ago
Would you like to create a PR for this issue?
I would try, except I have no idea what causes this behavior - I tried this with Mercurius driver and it works just fine
You can probably disable this behavior if you create a custom error formatter. You can provide the error formatter in the GraphQL options with the formatError
argument
You can probably disable this behavior if you create a custom error formatter. You can provide the error formatter in the GraphQL options with the formatError argument
I have tried this and it did not resolve the problem.
Is there an existing issue for this?
Current behavior
In Apollo, there's a way of providing a custom http status via
extensions
on theGraphQLError
/ApolloError
, as is the case with the default validation error, which returns a status of 400. Unfortunately, instead of the response being formatted the usual way - withdata
anderrors
, everything gets wrapped inside of theerror
object. Is there any way to disable this behavior?Minimum reproduction code
https://github.com/remonke/nest-graphql-error-bug
Steps to reproduce
Install the dependencies
pnpm install
Start the server Open the playground Test the two available queriesthrowError
andthrowErrorWithHttpStatus
Expected behavior
I expect a GraphQL errror with a custom http status to get formatted like all the others.
Package version
12.0.8
Graphql version
graphql
:16.7.1
@apollo/server
:4.8.1
@nestjs/apollo
:^12.0.7
NestJS version
10.0.0
Node.js version
20.4.0
In which operating systems have you tested?
Other
No response