fix: premarshal structs get generated with omitempty tag (#267)
This PR addresses a bug described in #263 Basically, whenever a struct involves a custom genqlient binding, a secondary "premarshal" struct gets generated. The bug was that this "premarshal" struct was not propagating the `omitempty` JSON tags, which was resulting in unexpected behavior. The fix involved a few changed lines in the Go template, and a few changes in the unit tests. I have: - [x] Written a clear PR title and description (above) - [x] Signed the [Khan Academy CLA](https://www.khanacademy.org/r/cla) - [x] Added tests covering my changes, if applicable - [x] Included a link to the issue fixed, if applicable - [x] Included documentation, for new features (n/a) - [x] Added an entry to the changelog
This commit is contained in:
+6
-6
@@ -148,19 +148,19 @@ func (v *UserQueryInput) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
type __premarshalUserQueryInput struct {
|
||||
Email string `json:"email"`
|
||||
Email string `json:"email,omitempty"`
|
||||
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
Id testutil.ID `json:"id"`
|
||||
|
||||
Role Role `json:"role"`
|
||||
Role Role `json:"role,omitempty"`
|
||||
|
||||
Names []string `json:"names"`
|
||||
Names []string `json:"names,omitempty"`
|
||||
|
||||
HasPokemon testutil.Pokemon `json:"hasPokemon"`
|
||||
HasPokemon testutil.Pokemon `json:"hasPokemon,omitempty"`
|
||||
|
||||
Birthdate json.RawMessage `json:"birthdate"`
|
||||
Birthdate json.RawMessage `json:"birthdate,omitempty"`
|
||||
}
|
||||
|
||||
func (v *UserQueryInput) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user