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
Where I work we use gRPC internally. When a repeated ProtoBuf field is sent over gRPC, there is no difference between a nil value and an empty value, so it reaches the server as nil (IIRC) and there's no way to discern whether the user supplied nil or an empty value. Of course, this distinction can be useful, if for example you're choosing whether to update something based on the presence of a value (e.g. set it to empty, vs. leave it alone in this case).
To work around this issue with gRPC and ProtoBuf, we made some wrapper types. For example:
GraphQL doesn't have this problem - there is a difference between a null array, and an empty array. I've already plumbed this in using a resolver for this field. In this GraphQL service we're building, we're trying to minimise the amount of manual mapping we're having to do, and so far this is the only thing we've having to manually map with a resolver.
So I'm wondering, can I add some sort of configuration to the GraphQL field, or to the gqlgen.yaml file which will allow me to provide another type for [String!] to map onto as a whole. We do already map the elements onto similar null.String values just fine, but the entire array needs to be able to map to one of these null.Strings types instead.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Where I work we use gRPC internally. When a
repeated
ProtoBuf field is sent over gRPC, there is no difference between anil
value and an empty value, so it reaches the server asnil
(IIRC) and there's no way to discern whether the user suppliednil
or an empty value. Of course, this distinction can be useful, if for example you're choosing whether to update something based on the presence of a value (e.g. set it to empty, vs. leave it alone in this case).To work around this issue with gRPC and ProtoBuf, we made some wrapper types. For example:
GraphQL doesn't have this problem - there is a difference between a
null
array, and an empty array. I've already plumbed this in using a resolver for this field. In this GraphQL service we're building, we're trying to minimise the amount of manual mapping we're having to do, and so far this is the only thing we've having to manually map with a resolver.So I'm wondering, can I add some sort of configuration to the GraphQL field, or to the
gqlgen.yaml
file which will allow me to provide another type for[String!]
to map onto as a whole. We do already map the elements onto similarnull.String
values just fine, but the entire array needs to be able to map to one of thesenull.Strings
types instead.Beta Was this translation helpful? Give feedback.
All reactions