Skip to content

Commit

Permalink
Merge pull request #781 from 99designs/fix-default-directives-init
Browse files Browse the repository at this point in the history
Set default directives after parsing config
  • Loading branch information
lwc authored Jul 11, 2019
2 parents d2c5bf2 + 8cab5fb commit 373359d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions codegen/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,7 @@ func DefaultConfig() *Config {
SchemaFilename: StringList{"schema.graphql"},
Model: PackageConfig{Filename: "models_gen.go"},
Exec: PackageConfig{Filename: "generated.go"},
Directives: map[string]DirectiveConfig{
"skip": {
SkipRuntime: true,
},
"include": {
SkipRuntime: true,
},
"deprecated": {
SkipRuntime: true,
},
},
Directives: map[string]DirectiveConfig{},
}
}

Expand Down Expand Up @@ -87,6 +77,18 @@ func LoadConfig(filename string) (*Config, error) {
return nil, errors.Wrap(err, "unable to parse config")
}

defaultDirectives := map[string]DirectiveConfig{
"skip": {SkipRuntime: true},
"include": {SkipRuntime: true},
"deprecated": {SkipRuntime: true},
}

for key, value := range defaultDirectives {
if _, defined := config.Directives[key]; !defined {
config.Directives[key] = value
}
}

preGlobbing := config.SchemaFilename
config.SchemaFilename = StringList{}
for _, f := range preGlobbing {
Expand Down

0 comments on commit 373359d

Please sign in to comment.