vendredi 28 août 2020

grpc-web protobuf compilation: How to enable jspb.Message.GENERATE_FROM_OBJECT option?

I have a react-app that uses grpc-web to interface with our grpc server. I want to be able to convert POJOs to the compiled GRPC classes so I can easily initiate requests. It seems like the protobuf compiler has an option jspb.Message.GENERATE_FROM_OBJECT that is set to false by default here:

https://github.com/protocolbuffers/protobuf/blob/master/js/message.js

It seems like this option is what I want: I can call Object.fromObject(pojo) and it will give me a protobuf class object that I can then initiate requests with. A similar function Object.toObject() already exists that gives me a POJO from a generated class object.

However, I cannot figure out a way to enable this option. How exactly do I make this happen?




Aucun commentaire:

Enregistrer un commentaire