1

How do you use oneof fields in a grpc node? I am using dynamic code generation. I tried to modify the quickstart with

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
  rpc SayHelloOneOf (OneOfRequest) returns (HelloReply) {}
}

message OneOfRequest {
  oneof nameOneof {
    string name = 1;
  }
}

However I do not know how to set the name in the request in the client. Thank you

user2133814
  • 2,431
  • 1
  • 24
  • 34

1 Answers1

1

Fields in a oneof are still directly part of the message, so you can still represent that message with an object like this:

{
  name: 'test name'
}

You can also set the field nameOneof to the value "name" to indicate which field of the oneof you are using.

murgatroid99
  • 19,007
  • 10
  • 60
  • 95