grpc / grpc-node

gRPC for Node.js
https://grpc.io
Apache License 2.0
4.47k stars 647 forks source link

proto-loader-gen-types shall generate an extra method definition for services which accepts arg: A and returns Observable<R> #1883

Closed nikotili closed 3 years ago

nikotili commented 3 years ago

I'm using NestJS to create a gRPC microservice and proto-loader-gen-types to generate types from the .proto file. However, generated interfaces only have methods which return SurfaceCall types like ClientUnaryCall and have a callback param like callback: (err, res: R) => void.

I'm suggesting a feature for proto-loader-gen-types to generate an extra method definition which looks like FindOne(arg: A, metadata?: Metadata): Observable<T> for the services.

I have considered using nestjs-proto-gen-ts which does exactly what I'm suggesting, but it lacks the generated methods from proto-loader-gen-types

murgatroid99 commented 3 years ago

The purpose of the type generator in the @grpc/proto-loader library is to generate types for objects output by the proto-loader library. Generating types for other libraries is out of scope for that type generator.