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:
@@ -170,6 +170,10 @@ func TestGenerateWithConfig(t *testing.T) {
|
||||
Generated: "generated.go",
|
||||
ContextType: "github.com/Khan/genqlient/internal/testutil.MyContext",
|
||||
}},
|
||||
{"StructReferences", "", &Config{
|
||||
StructReferences: true,
|
||||
Generated: "generated-structrefs.go",
|
||||
}},
|
||||
{"NoContext", "", &Config{
|
||||
Generated: "generated.go",
|
||||
ContextType: "-",
|
||||
|
||||
Reference in New Issue
Block a user