grpc-node
grpc-node copied to clipboard
Update grpc documentation & code example for multi-word proto fields
Lack of documentation on naming convention w/ json in grpc-js.
Is your feature request related to a problem? Please describe.
When using grpc-js w/ proto fields that have multiple words delimited w/ '_', the naming convention in the request/response object is different ( request fields require camel capitalization )
i.e. :
some.proto
...
rpc SomeRpc(Request) returns (Response)
message Request{
...
string some_string_field = 1;
}
message Response{
...
string another_string_field = 1;
}
some_client_impl.js
....
client.someRpc({someStringField:"some string to pass"}, (err, data) => {
...
console.log(data.anotherStringField)
})
Describe the solution you'd like
At minimum the documentation here to detail this requirement out. Ideally the associated code example should be updated to showcase this.
In your example JS code, you interact with both the request and response objects using camel case field names, so that is consistent. And that is actually not what happens in the linked example documentation because that code loads the proto file using the keepCase
option, which causes the JS field names to be exactly the same as the field names in the proto file. In particular, in that example proto file, the RouteSummary
message has a field named elapsed_time
, and the example code accesses it as stats.elapsed_time
.