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:
Kevin Chen
2023-05-05 09:05:20 -07:00
committed by GitHub
parent 4073a49614
commit 15f507b8de
8 changed files with 177 additions and 22 deletions
+7
View File
@@ -0,0 +1,7 @@
# @genqlient(pointer: true)
query GetPokemon($where: getPokemonBoolExp!) {
getPokemon(where: $where) {
species
level
}
}
+20
View File
@@ -180,8 +180,28 @@ type Query {
listOfListsOfListsOfContent: [[[Content!]!]!]!
recur(input: RecursiveInput!): Recursive
acceptsListOfListOfListsOfDates(datesss: [[[Date!]!]!]!): Boolean
getPokemon(where: getPokemonBoolExp): [Pokemon!]!
}
type Mutation {
createUser(name: String!, email: String): User
}
input getPokemonBoolExp {
_and: [getPokemonBoolExp!]
_not: getPokemonBoolExp
_or: [getPokemonBoolExp!]
level: IntComparisonExp
}
input IntComparisonExp {
_eq: Int
_gt: Int
_gte: Int
_in: [Int!]
_isNull: Boolean
_lt: Int
_lte: Int
_neq: Int
_nin: [Int!]
}