nestjs / graphql

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

MiddlewareContext in @nestjs/graphql assumes 'info' is always present on the context object #2824

Open einkria opened 1 year ago

einkria commented 1 year ago

Is there an existing issue for this?

Current behavior

In @nestjs/graphql 11.0.4 there is an interface called MiddlewareContext. There the assumption is made that the field info: GrapQLResolveInfo is always present on the context object. That however is not true. Info can be null or undefined. In our case the info field is not present on qraphql sub-requests. We are using @apollo/client 3.7.10.

Further info:

Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-vxhuhx?file=src%2Fmiddleware.ts

Steps to reproduce

See code snippet.

Expected behavior

Info field is made optional on the MiddlewareContext object to reflect the actuality of the GraphQL implementation.

Package

Other package

@nestjs/graphql

NestJS version

9.3.12

Packages versions

[Nest Platform Information] platform-express version : 9.3.12 event-emitter version : 1.4.1 schematics version : 9.0.4 throttler version : 4.0.0 schedule version : 2.2.0 terminus version : 9.2.2 graphql version : 11.0.4 swagger version : 6.2.1 typeorm version : 9.0.1 testing version : 9.3.12 apollo version : 11.0.4 common version : 9.3.12 config version : 2.3.1 axios version : 2.0.0 core version : 9.3.12

Node.js version

16.19.0

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 1 year ago

Would you like to create a PR for this issue?