-
Notifications
You must be signed in to change notification settings - Fork 348
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
Feat/check field optional proto #6137
Conversation
🦋 Changeset detectedLatest commit: 65d1844 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
* commit 'e0ac7512a': refactor: refactor checking optional for grpc reflection
@Q00 would it be possible to get some insides why did you close this PR ? |
@visma-alexander-maslov I made summary in my linkedin. I give you an english version below. m If you look at the official documentation for protobuf (https://protobuf.dev/), there are a lot of tips and tricks, and one of the best practices is not to make fields require. https://protobuf.dev/programming-guides/dos-donts/#add-required This also means that a well-formed message should be optional by default. I think it's in line with this statement that "optional" was present in proto2 and disappeared for a while in proto3. However, starting with v3.15, the story is different: explicit optional appears in proto3. This new concept changed the way we checked the default field and the field of explicit optional: we checked if a null value exists in the field, which redefined the meaning of null and default value. The problem was that when we communicated with explicit optional and no presence, there was a round trip loss because we couldn't check if it existed as a default value or if it was null. Therefore, I think that after 3.15, we should check the optional and non-optional fields of protobuf and map them to (explicit optional) graphql nullable if proto3 optional, and non-nullable if not. For nodejs servers, there is a PR that allows you to check proto3 optional in protobufjs to return null or undefined. protobufjs/protobuf.js#1611 In GraphQL, nullable fields on the input part map well to proto3 optional. This is especially useful in cases like "patch". On the other hand, in the output part, you need to follow the conventions for each programming language to return the default value. For example, for Node.js, the protobufjs library allows you to return the default value as is. Additionally, you need the proto3 optional to return null. However, if you use the Go language, you need proto3 optional to return the default value. |
🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.
Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of
the pull request.
Description
I want to make proto field not nullable when the proto field doesn't have optional keyword.
Because always proto field has default value ( Int32 -> 0, string -> "").
I saw the #5590 issue and I made the version of fixing it.
This PR makes graphql field required when proto field doesn't have 'optional'.
Fixes #5590 (issue)
Discussion: #6134
Type of change
Please delete options that are not relevant.
Screenshots/Sandbox (if appropriate/relevant):
after bob build command ( graphql-mesh repository )
after mesh build command ( service )
api.rpto
How Has This Been Tested?
Test Environment:
Checklist:
CONTRIBUTING doc and the
style guidelines of this project
Further comments
I made a new snapshot of required field schema version. Please check it.
If you want to see optional test, I will make it.