-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
4073a49
commit 15f507b
Showing
8 changed files
with
177 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @genqlient(pointer: true) | ||
query GetPokemon($where: getPokemonBoolExp!) { | ||
getPokemon(where: $where) { | ||
species | ||
level | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
generate/testdata/snapshots/TestGenerate-Hasura.graphql-Hasura.graphql.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
generate/testdata/snapshots/TestGenerate-Hasura.graphql-Hasura.graphql.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"operations": [ | ||
{ | ||
"operationName": "GetPokemon", | ||
"query": "\nquery GetPokemon ($where: getPokemonBoolExp!) {\n\tgetPokemon(where: $where) {\n\t\tspecies\n\t\tlevel\n\t}\n}\n", | ||
"sourceLocation": "testdata/queries/Hasura.graphql" | ||
} | ||
] | ||
} |
28 changes: 14 additions & 14 deletions
28
.../testdata/snapshots/TestGenerate-MultipleDirectives.graphql-MultipleDirectives.graphql.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
generate/testdata/snapshots/TestGenerate-Omitempty.graphql-Omitempty.graphql.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.