diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-04-09 21:45:24 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-04-09 21:45:24 +0200 |
commit | 26b5343e2160de172969e6834074cf8482ceb845 (patch) | |
tree | 04f27aa660a903d65f7b3d951bd1c6f92c59c0c3 /vendor/github.com/99designs/gqlgen/codegen/models_build.go | |
parent | 6e8496f4c1767ca8a8b95716a04f1b492bef7397 (diff) | |
download | git-bug-26b5343e2160de172969e6834074cf8482ceb845.tar.gz |
Update Gopkg.*
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/codegen/models_build.go')
-rw-r--r-- | vendor/github.com/99designs/gqlgen/codegen/models_build.go | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/vendor/github.com/99designs/gqlgen/codegen/models_build.go b/vendor/github.com/99designs/gqlgen/codegen/models_build.go deleted file mode 100644 index 56d2ff1f..00000000 --- a/vendor/github.com/99designs/gqlgen/codegen/models_build.go +++ /dev/null @@ -1,91 +0,0 @@ -package codegen - -import ( - "sort" - - "github.com/vektah/gqlparser/ast" - "golang.org/x/tools/go/loader" -) - -func (cfg *Config) buildModels(types NamedTypes, prog *loader.Program) ([]Model, error) { - var models []Model - - for _, typ := range cfg.schema.Types { - var model Model - switch typ.Kind { - case ast.Object: - obj, err := cfg.buildObject(types, typ) - if err != nil { - return nil, err - } - if obj.Root || obj.IsUserDefined { - continue - } - model = cfg.obj2Model(obj) - case ast.InputObject: - obj, err := cfg.buildInput(types, typ) - if err != nil { - return nil, err - } - if obj.IsUserDefined { - continue - } - model = cfg.obj2Model(obj) - case ast.Interface, ast.Union: - intf := cfg.buildInterface(types, typ, prog) - if intf.IsUserDefined { - continue - } - model = int2Model(intf) - default: - continue - } - model.Description = typ.Description // It's this or change both obj2Model and buildObject - - models = append(models, model) - } - - sort.Slice(models, func(i, j int) bool { - return models[i].GQLType < models[j].GQLType - }) - - return models, nil -} - -func (cfg *Config) obj2Model(obj *Object) Model { - model := Model{ - NamedType: obj.NamedType, - Implements: obj.Implements, - Fields: []ModelField{}, - } - - model.GoType = ucFirst(obj.GQLType) - model.Marshaler = &Ref{GoType: obj.GoType} - - for i := range obj.Fields { - field := &obj.Fields[i] - mf := ModelField{Type: field.Type, GQLName: field.GQLName} - - if field.GoFieldName != "" { - mf.GoFieldName = field.GoFieldName - } else { - mf.GoFieldName = field.GoNameExported() - } - - model.Fields = append(model.Fields, mf) - } - - return model -} - -func int2Model(obj *Interface) Model { - model := Model{ - NamedType: obj.NamedType, - Fields: []ModelField{}, - } - - model.GoType = ucFirst(obj.GQLType) - model.Marshaler = &Ref{GoType: obj.GoType} - - return model -} |