You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you said, it contains binary encoding and decoding runtime code.
But depending on the client impl detail, you don't actually need to use the encoding and decoding cost at runtime.
And I'm not sure if it's possible to make the existing code follow the ./meta-definition you suggested.
And in my opinion, if you put the value emitted by grpc gateway into trpc without a separate decoding process, there will be a problem.
Because protobuf's canonical json serialization format (grpc gateway will send the message in this way) and pbkit's message type are different. (I intentionally designed it differently to handle the map type and oneof easily in TypeScript)
So you need a runtime to decode the json sent by grpc-gateway into pbkit message type.
And you probably don't need trpc to create a client that talks to grpc-gateway with pbkit.
I think just making the client impl with fetch api (or axios) for grpc-gateway is enough.
This issue is a feature request.
What feature
A generator which output TypeScript code which has no runtime and
protobuf
encode/decode relative logic.It should be a clean TypeScript code one-to-one mapping to
proto
schema.For example, the output code is:
And the
./meta-definition
is:Why
There are common use scenarios which are only using
proto
as API protocol.The backend use grpc-gateway to expose HTTP server.
And the frontend use traditional HTTP to communicate with backend.
In such case, trpc like client is desired.
For leveraging meta-programming, such as
Proxy
, schema isomorphic TypeScript definition is required.I am happy to make an MR for that.
The text was updated successfully, but these errors were encountered: