# @genqlient(for: "Input.nonOptionalField", omitempty: false)
not working
#290
Labels
bug
Something isn't working
help wanted
Issues that anyone could pick up and implement if useful to them
Milestone
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/genqlient@v0.5.0
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: