How to resolve Enums as String values with Node grpc?

Using grpc with Node, Enums in responses to my queries are resolving as integer values. However, when I make the same queries with BloomRPC, the Enums resolve as Integer values.

Is there a parameter or option to force these Enums to be resolved as String using Node grpc?

Answer

If you are using the @grpc/proto-loader library, you can set the option enums to the value String (not the string “String”, the constructor function String). Then all enum values will be represented by their name strings.

Leave a Reply

Your email address will not be published. Required fields are marked *