Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 of 15 tasks
einkria opened this issue May 4, 2023 · 2 comments
Closed
3 of 15 tasks

Comments

@einkria
Copy link

einkria commented May 4, 2023

Is there an existing issue for this?

  • I have searched the existing issues

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:

  • For graphQL we use federation and generate the schema with the code-first approach
  • We observed the issue in a query that returns an entity which contains an external field (sub-request)
  • The external field is resolved to the correct sub-graph, but in the sub-graph's field middleware we receive a context that does not adhere to the MiddlewareContext interface
    • info is undefined

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

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

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?

  • macOS
  • Windows
  • Linux

Other

No response

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/nest May 15, 2023
@kamilmysliwiec kamilmysliwiec reopened this Nov 8, 2023
@kamilmysliwiec
Copy link
Member

Let's track this here #3314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants