You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there! I'm in need of being able to pass null for fields from my public API to private gRPC services.
I understand the best approach for this is using the well-known wrapper types, such as StringValue.
I also want to do automatic wrapping and unwrapping of these wrapper types.
I am able to encode {} for these fields, which I can interpret as absence of value (but presence of key), but I'd like to use null everywhere.
I looked into a few already-existing reported issues, and understand I can override the toObject and fromObject of protobuf.wrappers['.google.protobuf.StringValue'] to achieve this, but this only seems to work in the toObject phase — the fromObject never receives null values.
protobuf.js version: <7.2.0>
Related issue: #677
Hey there! I'm in need of being able to pass
null
for fields from my public API to private gRPC services.I understand the best approach for this is using the well-known wrapper types, such as
StringValue
.I also want to do automatic wrapping and unwrapping of these wrapper types.
I am able to encode
{}
for these fields, which I can interpret as absence of value (but presence of key), but I'd like to usenull
everywhere.I looked into a few already-existing reported issues, and understand I can override the
toObject
andfromObject
ofprotobuf.wrappers['.google.protobuf.StringValue']
to achieve this, but this only seems to work in thetoObject
phase — thefromObject
never receivesnull
values.Example code (js, proto and stdout): https://gist.github.com/lautarodragan/52fd05a9e261b7e22c27f4eae41baf1a
I see the generated code for
MyHappyProto.fromObject
is this:If the field is
null
,fromObject
is not called at all — I get no chance to transformnull
into{}
in thefromObject
phase.I guess these checks come from
protobuf.js/src/converter.js
Lines 144 to 147 in 0099ddc
The
toObject
correctly transforms{}
intonull
and{ value: 'string' }
intostring
.Can these checks be disabled somehow? Otherwise, is there an alternative to
fromObject
that I can work with?The text was updated successfully, but these errors were encountered: