genqlient
genqlient copied to clipboard
Annotated optional fields with `omitempty` by using new optional config value
It could be useful to annotate optional fields annotate with omitempty
when using pointers.
By allowing this option, input fields that get removed (and not used is the executed queries) will not break.
This gives the library an advantage to be more resilient against break API changes.
To introduce this option, a new optional
config value is introduced pointer_omitempty
.
If optional: pointer_omitempty
is set. We generate
type Task_insert_input struct {
Id: *int `json:"id,omitempty"`
}
based on
input task_insert_input {
id: Int
}
The @genqlient(omitempty)
config will override the previous defined config.
I have:
- [x] Written a clear PR title and description (above)
- [x] Signed the Khan Academy CLA
- [x] Added tests covering my changes, if applicable
- [ ] Included a link to the issue fixed, if applicable
- [x] Included documentation, for new features
- [x] Added an entry to the changelog
@benjaminjkraft Thanks for the feedback. I updated the PR accordingly. I hope I understood your suggestion correctly.