Add "struct_references" configuration (#155)

Adds a "struct_references" configuration that will:

* Use a pointer type for struct fields that are a complex type
* The behaviour can be overridden by setting "pointer: false" in the
  proceeding comment blocks
* Sets the "omitempty: true" flag on fields matching the criteria.
  This can also be overriden by setting "omitempty: false"

Although we'd debated not setting the pointer for array elements, it did turn out to be simpler to set them everywhere and also made the documentation cleaner to have a single rule to explain.

Fixes #149.
This commit is contained in:
Nathan Stitt
2021-11-12 19:53:19 -08:00
committed by GitHub
parent 5401a62dcb
commit 2fdbb629be
5 changed files with 92 additions and 1 deletions
+11
View File
@@ -77,6 +77,17 @@ context_type: context.Context
# without making a query.
client_getter: "github.com/you/yourpkg.GetClient"
# If set, fields with a struct type will default to having
# the "pointer: true, omitempty: true" flag.
#
# This can be useful for struct schema where it would be burdensome
# to manually set the flags on a large number of fields.
#
# Defaults to false.
use_struct_references: boolean
# A map from GraphQL type name to Go fully-qualified type name to override
# the Go type genqlient will use for this GraphQL type.
#