stephenh / ts-proto

An idiomatic protobuf generator for TypeScript
Apache License 2.0
2.08k stars 340 forks source link

Optional gRPC Metadata params for NestJS service client methods #322

Open moles1 opened 3 years ago

moles1 commented 3 years ago

The addGrpcMetadata flag for NestJS mode is a really nice feature, but it seems like the behaviour should be different wrt the generated Controller vs Client interfaces. i.e. imo it would be more useful as an optional parameter to the Client methods, so that the metadata arg doesn't need to be explicitly passed in that context. It still makes perfect sense as a required parameter to the Controller methods.

Obviously, one could easily ignore the addGrpcMetadata flag and simply use addNestjsRestParameter instead, then:

However, this could still be a nice QoL improvement :)

moles1 commented 3 years ago

Additionally, the NestJS gRPC documentation now describes a third grpc.ServerUnaryCall<any> parameter to Controller methods (see https://docs.nestjs.com/microservices/grpc#grpc-metadata), although I'm unsure how often this is utilized in practice and whether it warrants inclusion in the generated types.

stephenh commented 3 years ago

@moles1 hey, sorry for the late follow up here, but I agree with both of your observations; if you could submit a PR that changes both, that'd be great! Thanks!