Skip to content

Commit

Permalink
Make gqngen StructFieldsAlwaysPointers configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaflamm committed Apr 17, 2024
1 parent 5eec23e commit 1cac0a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ func LoadConfig(filename string) (*Config, error) {
sources = append(sources, &ast.Source{Name: filename, Input: string(schemaRaw)})
}

structFieldsAlwaysPointers := true
if cfg.Generate != nil && cfg.Generate.StructFieldsAlwaysPointers != nil {
structFieldsAlwaysPointers = *cfg.Generate.StructFieldsAlwaysPointers
}

cfg.GQLConfig = &config.Config{
Model: cfg.Model,
Models: models,
Expand All @@ -209,7 +214,7 @@ func LoadConfig(filename string) (*Config, error) {
Exec: config.ExecConfig{Filename: "generated.go"},
Directives: map[string]config.DirectiveConfig{},
Sources: sources,
StructFieldsAlwaysPointers: true,
StructFieldsAlwaysPointers: structFieldsAlwaysPointers,
ReturnPointersInUmarshalInput: false,
ResolversAlwaysReturnPointers: true,
NullableInputOmittable: false,
Expand Down
3 changes: 2 additions & 1 deletion config/generate_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ type GenerateConfig struct {
OmitEmptyTypes *bool `yaml:"omitEmptyTypes,omitempty"`
// Deprecated: not working because v1 is deleted. Must use ClientV2
// if true, used client v2 in generate code
ClientV2 bool `yaml:"clientV2,omitempty"`
ClientV2 bool `yaml:"clientV2,omitempty"`
StructFieldsAlwaysPointers *bool `yaml:"struct_fields_always_pointers,omitempty"`
}

func (c *GenerateConfig) ShouldGenerateClient() bool {
Expand Down

0 comments on commit 1cac0a8

Please sign in to comment.