-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
google.protobuf.Struct always empty #1106
Comments
Hi @CaioF ! I believe you are running into #852 , where NestJS's grpc integration does not successfully go through ts-proto's blessed The It's been awhile since I've dug into that issue, but I'm 90% sure that's what you're running into. Fwiw a big part of our ts-proto 2.x release was moving to I'd love to have you/someone dig into #852 , and finally fix that for NestJS users, as it's been a pita for awhile. :-/ Thanks! |
@stephenh thanks for pointing me to the issue, I will take a deeper look at it! |
@CaioF actually what we did is writing a "custom grpc-loader" that return something like:
where serviceDefinition come from the loaderOptions of nest:
Where serviceWithPackageName is ${packageName}.${serviceName} and generatedService is actually the grpc-js service generated by ts-proto |
I see, so that is just for loading not for encoding. Did you face the issue with using google.protobuf types in ts-proto with NestJS? The one in the link I sent you. Basically I can't find any way to use Google's well known types with ts-proto and nestJS because nestJS just does not use the encoders from ts-proto. |
we actually use google wrappers and it seralize/deserialez it perfectly. for example StringValue will be get deserialized to: property: string | undefined; |
How do you do that? Because whenever I use the types from ts-proto (i.e. Struct) they always fail to get serialized and come up as empty objects in the server. See the example I linked #1106 |
@eladhaim if you want I can setup an example repo, let me know if that would be helpful. |
let's say we have a service with package name: our loader will return
the generated service includes the seralization/desarialization details. |
Hey
ts-proto
mantainers 👋I have an issue with google.protobuf values always being empty.
I have a nestJS monorepo with a gRPC microservice,
common.proto
Using
npx protoc --plugin=./node_modules/.bin/protoc-gen_ts_proto --ts_proto_out=./ --ts_proto_opt=snakeToCamel=false --ts_proto_opt=env=node --ts_proto_opt=nestJs=true ./proto/common.proto
This builds into
common.ts
:And then, using the nest microservice package to create a client the following payload being sent:
The message is received by the gRPC server, however the data parameter is empty, on the logs of the gRPC server it shows:
The text was updated successfully, but these errors were encountered: