Closed 2Kable closed 4 years ago
This is intentional, see docs: https://docs.nestjs.com/guards#binding-guards
Hi, I get that this is intended, but is this design improvable ?
Not being able to set global guard/interceptors for nest-grpc running in an hybrid application, greatly reduce the experience of it.
My use case is: I want to run grpc alongside the graphql/http instance, and being able to intercept all request to log them is kinda basic.
And there's currently no way to set it up in an hybrid, or event create a NestMicroservice instance ourselves and attach it to the NestApplication
The change can be non breakable, and greatly improve the hybrid experience
@2Kable totally agree with you!
Bug Report
Similar to #353 but with suggestion to fix
Current behavior
When connecting a microservice to a NestApplication I would expect it to inherit configuration like Interceptors and such
In this case the microservice will not inherit the Application global interceptor
this is caused in packages/core/nest-application.ts
NestMicroservice
instance is instantiated with a wholenew ApplicationConfig()
Expected behavior
I would expect that hybrid application can share the same
ApplicationConfig
Possible Solution
We fixed it by patching nest source code and passing the
NestApplication
config in theNestMicroservice
constructorBut this would lead to a huge breaking change for current application that wants a separate configuration.
I would suggest an optional argument/property to pass to the
connectMicroservice
function to use the existingApplicationConfig
instanceAnother solution could be adding a method to attach a
NestMicroservice
instance to the NestApplication without relying on connectMicroserviceEnvironment