diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-08-17 00:48:08 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-08-17 00:48:08 +0200 |
commit | d571deef57b682f92e71f9374c2c59893db811af (patch) | |
tree | b17be26cfd358b1518010c9d7073fdbf0caa1561 /vendor/github.com/99designs/gqlgen/codegen/config | |
parent | a89355e7fbcaaa5efb07d43c1f19a4be2e2c1537 (diff) | |
download | git-bug-d571deef57b682f92e71f9374c2c59893db811af.tar.gz |
vendor: upgrade github.com/99designs/gqlgen to v0.9.2
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/codegen/config')
-rw-r--r-- | vendor/github.com/99designs/gqlgen/codegen/config/config.go | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/vendor/github.com/99designs/gqlgen/codegen/config/config.go b/vendor/github.com/99designs/gqlgen/codegen/config/config.go index c7a7d4d8..8e8992e3 100644 --- a/vendor/github.com/99designs/gqlgen/codegen/config/config.go +++ b/vendor/github.com/99designs/gqlgen/codegen/config/config.go @@ -16,7 +16,7 @@ import ( "github.com/pkg/errors" "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/ast" - yaml "gopkg.in/yaml.v2" + "gopkg.in/yaml.v2" ) type Config struct { @@ -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{}, } } @@ -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 { @@ -308,10 +310,10 @@ func (tm TypeMap) ReferencedPackages() []string { return pkgs } -func (tm TypeMap) Add(Name string, goType string) { - modelCfg := tm[Name] +func (tm TypeMap) Add(name string, goType string) { + modelCfg := tm[name] modelCfg.Model = append(modelCfg.Model, goType) - tm[Name] = modelCfg + tm[name] = modelCfg } type DirectiveConfig struct { @@ -457,9 +459,9 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { schemaStrings := map[string]string{} - var sources []*ast.Source + sources := make([]*ast.Source, len(c.SchemaFilename)) - for _, filename := range c.SchemaFilename { + for i, filename := range c.SchemaFilename { filename = filepath.ToSlash(filename) var err error var schemaRaw []byte @@ -469,7 +471,7 @@ func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { os.Exit(1) } schemaStrings[filename] = string(schemaRaw) - sources = append(sources, &ast.Source{Name: filename, Input: schemaStrings[filename]}) + sources[i] = &ast.Source{Name: filename, Input: schemaStrings[filename]} } schema, err := gqlparser.LoadSchema(sources...) |