diff options
author | Michael Muré <batolettre@gmail.com> | 2020-02-05 22:03:19 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-02-05 22:33:03 +0100 |
commit | 1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6 (patch) | |
tree | e088b0fa43058afde1db71541d8fcb4b94905d6e /vendor/github.com/99designs/gqlgen/plugin/schemaconfig | |
parent | f093be96e98284580d61664adecd0a2ff8b354e4 (diff) | |
download | git-bug-1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6.tar.gz |
migrate to go modules
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/plugin/schemaconfig')
-rw-r--r-- | vendor/github.com/99designs/gqlgen/plugin/schemaconfig/schemaconfig.go | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/vendor/github.com/99designs/gqlgen/plugin/schemaconfig/schemaconfig.go b/vendor/github.com/99designs/gqlgen/plugin/schemaconfig/schemaconfig.go deleted file mode 100644 index 1fcf4105..00000000 --- a/vendor/github.com/99designs/gqlgen/plugin/schemaconfig/schemaconfig.go +++ /dev/null @@ -1,93 +0,0 @@ -package schemaconfig - -import ( - "github.com/99designs/gqlgen/codegen/config" - "github.com/99designs/gqlgen/plugin" - "github.com/vektah/gqlparser/ast" -) - -func New() plugin.Plugin { - return &Plugin{} -} - -type Plugin struct{} - -var _ plugin.ConfigMutator = &Plugin{} - -func (m *Plugin) Name() string { - return "schemaconfig" -} - -func (m *Plugin) MutateConfig(cfg *config.Config) error { - if err := cfg.Check(); err != nil { - return err - } - - schema, _, err := cfg.LoadSchema() - if err != nil { - return err - } - - cfg.Directives["goModel"] = config.DirectiveConfig{ - SkipRuntime: true, - } - - cfg.Directives["goField"] = config.DirectiveConfig{ - SkipRuntime: true, - } - - for _, schemaType := range schema.Types { - if schemaType == schema.Query || schemaType == schema.Mutation || schemaType == schema.Subscription { - continue - } - - if bd := schemaType.Directives.ForName("goModel"); bd != nil { - if ma := bd.Arguments.ForName("model"); ma != nil { - if mv, err := ma.Value.Value(nil); err == nil { - cfg.Models.Add(schemaType.Name, mv.(string)) - } - } - if ma := bd.Arguments.ForName("models"); ma != nil { - if mvs, err := ma.Value.Value(nil); err == nil { - for _, mv := range mvs.([]interface{}) { - cfg.Models.Add(schemaType.Name, mv.(string)) - } - } - } - } - - if schemaType.Kind == ast.Object || schemaType.Kind == ast.InputObject { - for _, field := range schemaType.Fields { - if fd := field.Directives.ForName("goField"); fd != nil { - forceResolver := cfg.Models[schemaType.Name].Fields[field.Name].Resolver - fieldName := cfg.Models[schemaType.Name].Fields[field.Name].FieldName - - if ra := fd.Arguments.ForName("forceResolver"); ra != nil { - if fr, err := ra.Value.Value(nil); err == nil { - forceResolver = fr.(bool) - } - } - - if na := fd.Arguments.ForName("name"); na != nil { - if fr, err := na.Value.Value(nil); err == nil { - fieldName = fr.(string) - } - } - - if cfg.Models[schemaType.Name].Fields == nil { - cfg.Models[schemaType.Name] = config.TypeMapEntry{ - Model: cfg.Models[schemaType.Name].Model, - Fields: map[string]config.TypeMapField{}, - } - } - - cfg.Models[schemaType.Name].Fields[field.Name] = config.TypeMapField{ - FieldName: fieldName, - Resolver: forceResolver, - } - } - } - } - } - return nil -} |