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

No way to inject context in gRPC method in NestJS #14077

Open
1 task done
yongyiwong opened this issue Oct 19, 2024 · 0 comments
Open
1 task done

No way to inject context in gRPC method in NestJS #14077

yongyiwong opened this issue Oct 19, 2024 · 0 comments
Labels
needs triage This issue has not been looked into type: enhancement 🐺

Comments

@yongyiwong
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Hey, as long as I have searched, I don't think there is a way to inject context in gRPC method.
You can do it in GraphQL resolver, and Http Controller using decorator.

Describe the solution you'd like

I recommend decorator in nest/microservice package.

Teachability, documentation, adoption, migration strategy

import { GrpcContext } from '@nestjs/microservices';

  async me(@GrpcContext() context: ExecutionContext): Promise<UserResponse> {
       return context?.user;
  }

What is the motivation / use case for changing the behavior?

Let's say in gRPC method, user info can be save in context of ExecutionContext, but can't be injected in gRPC method.
It will be very good to be implemented.

@yongyiwong yongyiwong added needs triage This issue has not been looked into type: enhancement 🐺 labels Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: enhancement 🐺
Projects
None yet
Development

No branches or pull requests

1 participant