connect-es icon indicating copy to clipboard operation
connect-es copied to clipboard

Support alternate protobuf "runtimes"

Open jonaskello opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. In our codebase using type aliases and plain javascript objects it the idiom for the application code. We are currently using ts-proto and custom built libraries for the infrastructure code to make this possible. The custom libraries we built are similar to connect-es so I was looking into if we could just use connect-es instead. What I found was that use of connect-es is dependent on the use of the specific flavor of classes generated by buf code generation. These do not fit in our codebase as we don't use classes, just plain objects and type aliases.

Here is an example of code causing the coupling: https://github.com/bufbuild/protobuf-es/blob/8745d7224980eff85344b68d018c956359626e3e/packages/protobuf/src/service-type.ts#L62

Describe the solution you'd like It was suggested in this comment that connect-es could support alternative "runtimes". I think this means being able to pass connect-es the serialization functions separate from the data. This way we could use any type of code generation we want and still make use of the connect-es libraries.

Please specify whether the request is for Connect for Web or Connect for Node.js. Both

Describe alternatives you've considered Building our own implementation of connect protocol from scratch. Would be nice to use the reference implementation to avoid that work.

Additional context I would like to avoid making this into a debate of what is idiomatic or not in javascript/typescript. If the request does not align with the goals of es-connect then please just close this issue instead.

jonaskello avatar Feb 28 '24 08:02 jonaskello

Great use cases for this feature:

  • https://github.com/connectrpc/connect-es/issues/1233
  • https://github.com/connectrpc/connect-es/issues/1287

timostamm avatar Oct 28 '24 13:10 timostamm