nestjs / graphql

GraphQL (TypeScript) module for Nest framework (node.js) 🍷
https://docs.nestjs.com/graphql/quick-start
MIT License
1.45k stars 392 forks source link

formatError not defined in GqlModuleOptions #2524

Closed equal-matt closed 1 year ago

equal-matt commented 1 year ago

Is there an existing issue for this?

Current behavior

The type definition for GQLModuleOptions doesn't accept formatError, making it impossible to intercept errors as they are emitted.

Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-ny1xwh?file=src/app.module.ts

Steps to reproduce

You can see the type problem in the reproduction code. The provided linter will highlight it and there's a comment on the appropriate line pointing at the extra type definition required to work around the problem.

You can also see that the option is merged correctly with the default options by making use of the GraphQL playground. Visit the /graphql route in the embedded browser and query for query { errors }. You will see the extra logging line output correctly.

Expected behavior

The type definition should be updated to allow for this option to be passed.

Package version

10.1.6

Graphql version

"@nestjs/apollo": "^10.1.6", "@nestjs/common": "^9.0.0", "@nestjs/core": "^9.0.0", "@nestjs/graphql": "^10.1.6", "@nestjs/platform-express": "^9.0.0", "apollo-server-express": "^3.11.1", "graphql": "^16.6.0",

NestJS version

9.0.0

Node.js version

16.14.2

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 1 year ago

You should use the ApolloDriverConfig interface

image

as shown in the docs https://docs.nestjs.com/graphql/quick-start#async-configuration