Skip to content

Commit

Permalink
Set default directives after parsing config
Browse files Browse the repository at this point in the history
  • Loading branch information
lwc committed Jul 8, 2019
1 parent d2c5bf2 commit 8cab5fb
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 8cab5fb

Please sign in to comment.