Global omitempty option
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 144
- Avg merge
- 4h 50m
- Merged PRs (30d)
- 1
Description
Let's say a graphql query accepts an input object, which has an optional string in it, if I use the input object, and not give a value to that string, it should be committed, that's just how graphql works.
Unfortunately, this library doesn't work that way.
**Is your feature request related to a problem? Please describe.**
I have this input for shopify, the non struct fields are not required

The generation works well, but if In don't include the optional fields, genqlient turns them into null (when defining value as pointer) or to an empty string (when defining value as value).
They should just be omitted as I don't want to send them, otherwise shopify will fail to use this.
Using the "@genqlient(omitempty: true)" is impossible, because the import is required, even tho every field on it is optional.
**Describe the solution you'd like**
add to the settings.yml file an option "omitempty: boolean" that would just cover all the json fields.
**Describe alternatives you've considered**
Adding manually the "omitempty" directive, but with thousands of fields it's makes it really hard to use, and time consuming and prone to humen errors.
**Additional context**
What I get generated, why would an optional pointer to a string not have omit empty?

Contributor guide
Research direction
Start by tracing how settings.yml is loaded and how GraphQL input fields become generated JSON fields. Define the global omitempty setting's behavior for optional fields, then verify that generated requests omit empty optional values without requiring per-field directives.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, graphql
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100