-
Notifications
You must be signed in to change notification settings - Fork 96
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
# @genqlient(for: "Input.nonOptionalField", omitempty: false)
not working
#290
Comments
Thanks for raising this. I agree this is a bug. We can probably just change the validation (here and a few |
Thank you for looking into it |
I want it to add omitempty to everything but
|
Describe the bug
Hey all 馃憢
We are having a use-case where we want to apply
omitempty
on all fields except a mandatory graphql field.We've tried the below code both at the top of the query and at the top of the
$input
line:# @genqlient(omitempty: true)
# @genqlient(for: "Input.nonOptionalField", omitempty: false)
But we got the error:
omitempty may only be used on optional arguments
Shouldn't
omitempty
be considered for non optional graphql fields when set tofalse
?When using
# @genqlient(omitempty: true)
only, it works on all fields including non optional graphql fields and adds thejson:"fieldname,omitempty"
to them.To Reproduce
Schema:
Query:
Happens at code generation running:
go run -mod=readonly github.com/Khan/[email protected]
Expected behavior
When using the below code at the top of the query:
# @genqlient(omitempty: true)
# @genqlient(for: "Input.nonOptionalField", omitempty: false)
I would expect
omitempty
to be added to all fields except theInput.nonOptionalField
one.I tested and it worked when using only optional fields.
genqlient version
Tested on both 0.5.0 and 0.6.0
The text was updated successfully, but these errors were encountered: