grpc / grpc-node

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

Generate the corresponding interface to the proto file. #537

Closed zuohuadong closed 2 years ago

zuohuadong commented 6 years ago

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

No, not a problem. Missing functionality.

Describe the solution you'd like

Generate the corresponding interface to the proto file.

syntax = "proto3";

package hero;

service HeroService {
  rpc FindOne (HeroById) returns (Hero) {}
}

message HeroById {
  int32 id = 1;
}

message Hero {
  int32 id = 1;
  string name = 2;
}

to (typescript)

interface HeroService {
  findOne(data: { id: number }): Observable<any>;
}

Describe alternatives you've considered

None

Additional context

reference: https://docs.nestjs.com/microservices/grpc

murgatroid99 commented 6 years ago

The code described in the linked documentation has different types than the code that gRPC generates directly. It looks like there is a layer of wrapping code provided by Nest. So, even if we did have a TypeScript generator, it would not be directly useful to Nest users.

For a discussion of the challenges of providing a TypeScript generator in general, please see #528.