diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1f897506..f9e67607 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -23,12 +23,13 @@ When releasing a new version: ### Breaking changes: - The [`graphql.Client`](https://pkg.go.dev/github.com/Khan/genqlient/graphql#Client) interface now accepts `variables interface{}` (containing a JSON-marshalable value) rather than `variables map[string]interface{}`. Clients implementing the interface themselves will need to change the signature; clients who simply call `graphql.NewClient` are unaffected. +- genqlient's handling of the `omitempty` option has changed to match that of `encoding/json`, from which it had inadvertently differed. In particular, this means struct-typed arguments with `# @genqlient(omitempty: true)` will no longer be omitted if they are the zero value. (Struct-pointers are still omitted if nil, so adding `pointer: true` will typically work fine.) ### New features: ### Bug fixes: -- The `omitempty` option now works correctly for struct- and map-typed variables, which is to say it never considers them empty (matching `encoding/json`). (#43) +- The `omitempty` option now works correctly for struct- and map-typed variables, matching `encoding/json`, which is to say it never omits structs, and omits empty maps. (#43) - Generated type-names now abbreviate across multiple components; for example if the path to a type is `(MyOperation, Outer, Outer, Inner, OuterInner)`, it will again be called `MyOperationOuterInner`. (This regressed in a pre-v0.1.0 refactor.) (#109) ## v0.1.0 diff --git a/generate/types.go b/generate/types.go index f5b58a34..3b70d84a 100644 --- a/generate/types.go +++ b/generate/types.go @@ -203,6 +203,9 @@ func (typ *goStructType) WriteDefinition(w io.Writer, g *generator) error { // select the same field, or several fragments select the same field -- the // JSON library will only fill one of those (the least-nested one); we want // to fill them all. + // + // TODO(benkraft): If/when proposal #5901 is implemented (Go 1.18 at the + // earliest), we may be able to do some of this a simpler way. if !needUnmarshaler { return nil }