Closed le0nik closed 3 years ago
Would it be fine to pass all arguments to the handler regardless of server type (get rid of those argsLenth/initialArgs)
This would break too many features.
maybe reverse the logic and pass 1 argument known server types(except GRPC) and pass everything to the others?
Would you like to create a PR for this issue?
Feature Request
Problem: I have a custom microservice implementation(
class MyServer extends Server implements CustomTransportStrategy
and a corresponding decorator) which calls controller handlers with(call.request, call.metadata, call)
, but nestjs only passescall.request
becausein
RpcContextCreator
https://github.com/nestjs/nest/blob/0d7b13ec53244f15f230e905afe3d463f6d5bf2b/packages/microservices/context/rpc-context-creator.ts#L118-L124 it calls controller handlers with just 1 argumentinitialArgs
, becausedefaultCallMetadata
length is 1, which is passed fromListenersController
and in
ListenersController
it checks forinstanceof ServerGrpc
to allow passing 3 arguments instead of 1, which isfalse
in my case https://github.com/nestjs/nest/blob/a683a545af3eaee64f2b1863b79e4fd73dbdeb26/packages/microservices/listeners-controller.ts#L60-L63As a temporary solution I had to only pass
call
argument, but would like to passrequest
andmetadata
separately.Would it be fine to pass all arguments to the handler regardless of server type (get rid of those argsLenth/initialArgs) or maybe reverse the logic and pass 1 argument to known server types(except GRPC) and pass everything to the others?
Haven't seen this restriction anywhere in the docs so it wasn't easy to wrap my head around why nest would just drop some of the arguments was passing.