Add support for mapping all nullable types as pointers (#198)

This implements the approach suggested in
https://github.com/Khan/genqlient/issues/178#issuecomment-1077559343.
See the added documentation for the full behavior.
This commit is contained in:
Chris Connelly
2022-05-24 12:24:06 -07:00
committed by GitHub
parent 3685f3f66b
commit 37fa3d6e7c
7 changed files with 336 additions and 17 deletions
+1 -1
View File
@@ -256,7 +256,7 @@ func (g *generator) convertType(
oe := true
options.Omitempty = &oe
}
} else if options.GetPointer() {
} else if options.GetPointer() || (!typ.NonNull && g.Config.Optional == "pointer") {
// Whatever we get, wrap it in a pointer. (Because of the way the
// options work, recursing here isn't as connvenient.)
// Note this does []*T or [][]*T, not e.g. *[][]T. See #16.