mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 10:12:06 +03:00
vendor: upgrade github.com/99designs/gqlgen to v0.9.2
This commit is contained in:
parent
a89355e7fb
commit
d571deef57
4
vendor/github.com/99designs/gqlgen/codegen/args.gotpl
generated
vendored
4
vendor/github.com/99designs/gqlgen/codegen/args.gotpl
generated
vendored
@ -14,6 +14,10 @@ func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string]
|
|||||||
}
|
}
|
||||||
if data, ok := tmp.({{ $arg.TypeReference.GO | ref }}) ; ok {
|
if data, ok := tmp.({{ $arg.TypeReference.GO | ref }}) ; ok {
|
||||||
arg{{$i}} = data
|
arg{{$i}} = data
|
||||||
|
{{- if $arg.TypeReference.IsNilable }}
|
||||||
|
} else if tmp == nil {
|
||||||
|
arg{{$i}} = nil
|
||||||
|
{{- end }}
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp)
|
return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp)
|
||||||
}
|
}
|
||||||
|
38
vendor/github.com/99designs/gqlgen/codegen/config/config.go
generated
vendored
38
vendor/github.com/99designs/gqlgen/codegen/config/config.go
generated
vendored
@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/vektah/gqlparser"
|
"github.com/vektah/gqlparser"
|
||||||
"github.com/vektah/gqlparser/ast"
|
"github.com/vektah/gqlparser/ast"
|
||||||
yaml "gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -38,17 +38,7 @@ func DefaultConfig() *Config {
|
|||||||
SchemaFilename: StringList{"schema.graphql"},
|
SchemaFilename: StringList{"schema.graphql"},
|
||||||
Model: PackageConfig{Filename: "models_gen.go"},
|
Model: PackageConfig{Filename: "models_gen.go"},
|
||||||
Exec: PackageConfig{Filename: "generated.go"},
|
Exec: PackageConfig{Filename: "generated.go"},
|
||||||
Directives: map[string]DirectiveConfig{
|
Directives: map[string]DirectiveConfig{},
|
||||||
"skip": {
|
|
||||||
SkipRuntime: true,
|
|
||||||
},
|
|
||||||
"include": {
|
|
||||||
SkipRuntime: true,
|
|
||||||
},
|
|
||||||
"deprecated": {
|
|
||||||
SkipRuntime: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +77,18 @@ func LoadConfig(filename string) (*Config, error) {
|
|||||||
return nil, errors.Wrap(err, "unable to parse config")
|
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
|
preGlobbing := config.SchemaFilename
|
||||||
config.SchemaFilename = StringList{}
|
config.SchemaFilename = StringList{}
|
||||||
for _, f := range preGlobbing {
|
for _, f := range preGlobbing {
|
||||||
@ -308,10 +310,10 @@ func (tm TypeMap) ReferencedPackages() []string {
|
|||||||
return pkgs
|
return pkgs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tm TypeMap) Add(Name string, goType string) {
|
func (tm TypeMap) Add(name string, goType string) {
|
||||||
modelCfg := tm[Name]
|
modelCfg := tm[name]
|
||||||
modelCfg.Model = append(modelCfg.Model, goType)
|
modelCfg.Model = append(modelCfg.Model, goType)
|
||||||
tm[Name] = modelCfg
|
tm[name] = modelCfg
|
||||||
}
|
}
|
||||||
|
|
||||||
type DirectiveConfig struct {
|
type DirectiveConfig struct {
|
||||||
@ -457,9 +459,9 @@ func (c *Config) InjectBuiltins(s *ast.Schema) {
|
|||||||
func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) {
|
func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) {
|
||||||
schemaStrings := map[string]string{}
|
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)
|
filename = filepath.ToSlash(filename)
|
||||||
var err error
|
var err error
|
||||||
var schemaRaw []byte
|
var schemaRaw []byte
|
||||||
@ -469,7 +471,7 @@ func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
schemaStrings[filename] = string(schemaRaw)
|
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...)
|
schema, err := gqlparser.LoadSchema(sources...)
|
||||||
|
5
vendor/github.com/99designs/gqlgen/codegen/data.go
generated
vendored
5
vendor/github.com/99designs/gqlgen/codegen/data.go
generated
vendored
@ -123,10 +123,7 @@ func BuildData(cfg *config.Config) (*Data, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
s.ReferencedTypes, err = b.buildTypes()
|
s.ReferencedTypes = b.buildTypes()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Slice(s.Objects, func(i, j int) bool {
|
sort.Slice(s.Objects, func(i, j int) bool {
|
||||||
return s.Objects[i].Definition.Name < s.Objects[j].Definition.Name
|
return s.Objects[i].Definition.Name < s.Objects[j].Definition.Name
|
||||||
|
14
vendor/github.com/99designs/gqlgen/codegen/field.go
generated
vendored
14
vendor/github.com/99designs/gqlgen/codegen/field.go
generated
vendored
@ -384,16 +384,16 @@ func (f *Field) ComplexitySignature() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Field) ComplexityArgs() string {
|
func (f *Field) ComplexityArgs() string {
|
||||||
var args []string
|
args := make([]string, len(f.Args))
|
||||||
for _, arg := range f.Args {
|
for i, arg := range f.Args {
|
||||||
args = append(args, "args["+strconv.Quote(arg.Name)+"].("+templates.CurrentImports.LookupType(arg.TypeReference.GO)+")")
|
args[i] = "args[" + strconv.Quote(arg.Name) + "].(" + templates.CurrentImports.LookupType(arg.TypeReference.GO) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(args, ", ")
|
return strings.Join(args, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Field) CallArgs() string {
|
func (f *Field) CallArgs() string {
|
||||||
var args []string
|
args := make([]string, 0, len(f.Args)+2)
|
||||||
|
|
||||||
if f.IsResolver {
|
if f.IsResolver {
|
||||||
args = append(args, "rctx")
|
args = append(args, "rctx")
|
||||||
@ -401,10 +401,8 @@ func (f *Field) CallArgs() string {
|
|||||||
if !f.Object.Root {
|
if !f.Object.Root {
|
||||||
args = append(args, "obj")
|
args = append(args, "obj")
|
||||||
}
|
}
|
||||||
} else {
|
} else if f.MethodHasContext {
|
||||||
if f.MethodHasContext {
|
args = append(args, "ctx")
|
||||||
args = append(args, "ctx")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, arg := range f.Args {
|
for _, arg := range f.Args {
|
||||||
|
5
vendor/github.com/99designs/gqlgen/codegen/field.gotpl
generated
vendored
5
vendor/github.com/99designs/gqlgen/codegen/field.gotpl
generated
vendored
@ -107,6 +107,11 @@
|
|||||||
if data, ok := tmp.({{ .TypeReference.GO | ref }}) ; ok {
|
if data, ok := tmp.({{ .TypeReference.GO | ref }}) ; ok {
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
{{- if .TypeReference.IsNilable -}}
|
||||||
|
else if tmp == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ .TypeReference.GO }}`, tmp)
|
return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ .TypeReference.GO }}`, tmp)
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
|
4
vendor/github.com/99designs/gqlgen/codegen/input.gotpl
generated
vendored
4
vendor/github.com/99designs/gqlgen/codegen/input.gotpl
generated
vendored
@ -25,6 +25,10 @@
|
|||||||
}
|
}
|
||||||
if data, ok := tmp.({{ $field.TypeReference.GO | ref }}) ; ok {
|
if data, ok := tmp.({{ $field.TypeReference.GO | ref }}) ; ok {
|
||||||
it.{{$field.GoFieldName}} = data
|
it.{{$field.GoFieldName}} = data
|
||||||
|
{{- if $field.TypeReference.IsNilable }}
|
||||||
|
} else if tmp == nil {
|
||||||
|
it.{{$field.GoFieldName}} = nil
|
||||||
|
{{- end }}
|
||||||
} else {
|
} else {
|
||||||
return it, fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp)
|
return it, fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp)
|
||||||
}
|
}
|
||||||
|
3
vendor/github.com/99designs/gqlgen/codegen/object.go
generated
vendored
3
vendor/github.com/99designs/gqlgen/codegen/object.go
generated
vendored
@ -114,8 +114,7 @@ func (o *Object) HasUnmarshal() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
for i := 0; i < o.Type.(*types.Named).NumMethods(); i++ {
|
for i := 0; i < o.Type.(*types.Named).NumMethods(); i++ {
|
||||||
switch o.Type.(*types.Named).Method(i).Name() {
|
if o.Type.(*types.Named).Method(i).Name() == "UnmarshalGQL" {
|
||||||
case "UnmarshalGQL":
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
vendor/github.com/99designs/gqlgen/codegen/templates/import.go
generated
vendored
3
vendor/github.com/99designs/gqlgen/codegen/templates/import.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go/types"
|
"go/types"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/99designs/gqlgen/internal/code"
|
"github.com/99designs/gqlgen/internal/code"
|
||||||
)
|
)
|
||||||
@ -20,7 +21,7 @@ type Imports struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Import) String() string {
|
func (i *Import) String() string {
|
||||||
if i.Alias == i.Name {
|
if strings.HasSuffix(i.Path, i.Alias) {
|
||||||
return strconv.Quote(i.Path)
|
return strconv.Quote(i.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
vendor/github.com/99designs/gqlgen/codegen/templates/templates.go
generated
vendored
14
vendor/github.com/99designs/gqlgen/codegen/templates/templates.go
generated
vendored
@ -285,7 +285,8 @@ func ToGoPrivate(name string) string {
|
|||||||
first := true
|
first := true
|
||||||
wordWalker(name, func(info *wordInfo) {
|
wordWalker(name, func(info *wordInfo) {
|
||||||
word := info.Word
|
word := info.Word
|
||||||
if first {
|
switch {
|
||||||
|
case first:
|
||||||
if strings.ToUpper(word) == word || strings.ToLower(word) == word {
|
if strings.ToUpper(word) == word || strings.ToLower(word) == word {
|
||||||
// ID → id, CAMEL → camel
|
// ID → id, CAMEL → camel
|
||||||
word = strings.ToLower(info.Word)
|
word = strings.ToLower(info.Word)
|
||||||
@ -294,9 +295,9 @@ func ToGoPrivate(name string) string {
|
|||||||
word = lcFirst(info.Word)
|
word = lcFirst(info.Word)
|
||||||
}
|
}
|
||||||
first = false
|
first = false
|
||||||
} else if info.MatchCommonInitial {
|
case info.MatchCommonInitial:
|
||||||
word = strings.ToUpper(word)
|
word = strings.ToUpper(word)
|
||||||
} else if !info.HasCommonInitial {
|
case !info.HasCommonInitial:
|
||||||
word = ucFirst(strings.ToLower(word))
|
word = ucFirst(strings.ToLower(word))
|
||||||
}
|
}
|
||||||
runes = append(runes, []rune(word)...)
|
runes = append(runes, []rune(word)...)
|
||||||
@ -319,9 +320,10 @@ func wordWalker(str string, f func(*wordInfo)) {
|
|||||||
hasCommonInitial := false
|
hasCommonInitial := false
|
||||||
for i+1 <= len(runes) {
|
for i+1 <= len(runes) {
|
||||||
eow := false // whether we hit the end of a word
|
eow := false // whether we hit the end of a word
|
||||||
if i+1 == len(runes) {
|
switch {
|
||||||
|
case i+1 == len(runes):
|
||||||
eow = true
|
eow = true
|
||||||
} else if isDelimiter(runes[i+1]) {
|
case isDelimiter(runes[i+1]):
|
||||||
// underscore; shift the remainder forward over any run of underscores
|
// underscore; shift the remainder forward over any run of underscores
|
||||||
eow = true
|
eow = true
|
||||||
n := 1
|
n := 1
|
||||||
@ -336,7 +338,7 @@ func wordWalker(str string, f func(*wordInfo)) {
|
|||||||
|
|
||||||
copy(runes[i+1:], runes[i+n+1:])
|
copy(runes[i+1:], runes[i+n+1:])
|
||||||
runes = runes[:len(runes)-n]
|
runes = runes[:len(runes)-n]
|
||||||
} else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) {
|
case unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]):
|
||||||
// lower->non-lower
|
// lower->non-lower
|
||||||
eow = true
|
eow = true
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/99designs/gqlgen/codegen/type.go
generated
vendored
4
vendor/github.com/99designs/gqlgen/codegen/type.go
generated
vendored
@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/99designs/gqlgen/codegen/config"
|
"github.com/99designs/gqlgen/codegen/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (b *builder) buildTypes() (map[string]*config.TypeReference, error) {
|
func (b *builder) buildTypes() map[string]*config.TypeReference {
|
||||||
ret := map[string]*config.TypeReference{}
|
ret := map[string]*config.TypeReference{}
|
||||||
|
|
||||||
for _, ref := range b.Binder.References {
|
for _, ref := range b.Binder.References {
|
||||||
@ -14,5 +14,5 @@ func (b *builder) buildTypes() (map[string]*config.TypeReference, error) {
|
|||||||
ref = ref.Elem()
|
ref = ref.Elem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret, nil
|
return ret
|
||||||
}
|
}
|
||||||
|
18
vendor/github.com/99designs/gqlgen/graphql/introspection/schema.go
generated
vendored
18
vendor/github.com/99designs/gqlgen/graphql/introspection/schema.go
generated
vendored
@ -11,7 +11,7 @@ type Schema struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schema) Types() []Type {
|
func (s *Schema) Types() []Type {
|
||||||
var types []Type
|
types := make([]Type, 0, len(s.schema.Types))
|
||||||
for _, typ := range s.schema.Types {
|
for _, typ := range s.schema.Types {
|
||||||
if strings.HasPrefix(typ.Name, "__") {
|
if strings.HasPrefix(typ.Name, "__") {
|
||||||
continue
|
continue
|
||||||
@ -34,7 +34,7 @@ func (s *Schema) SubscriptionType() *Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schema) Directives() []Directive {
|
func (s *Schema) Directives() []Directive {
|
||||||
var res []Directive
|
res := make([]Directive, 0, len(s.schema.Directives))
|
||||||
|
|
||||||
for _, d := range s.schema.Directives {
|
for _, d := range s.schema.Directives {
|
||||||
res = append(res, s.directiveFromDef(d))
|
res = append(res, s.directiveFromDef(d))
|
||||||
@ -44,19 +44,19 @@ func (s *Schema) Directives() []Directive {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schema) directiveFromDef(d *ast.DirectiveDefinition) Directive {
|
func (s *Schema) directiveFromDef(d *ast.DirectiveDefinition) Directive {
|
||||||
var locs []string
|
locs := make([]string, len(d.Locations))
|
||||||
for _, loc := range d.Locations {
|
for i, loc := range d.Locations {
|
||||||
locs = append(locs, string(loc))
|
locs[i] = string(loc)
|
||||||
}
|
}
|
||||||
|
|
||||||
var args []InputValue
|
args := make([]InputValue, len(d.Arguments))
|
||||||
for _, arg := range d.Arguments {
|
for i, arg := range d.Arguments {
|
||||||
args = append(args, InputValue{
|
args[i] = InputValue{
|
||||||
Name: arg.Name,
|
Name: arg.Name,
|
||||||
Description: arg.Description,
|
Description: arg.Description,
|
||||||
DefaultValue: defaultValue(arg.DefaultValue),
|
DefaultValue: defaultValue(arg.DefaultValue),
|
||||||
Type: WrapTypeFromType(s.schema, arg.Type),
|
Type: WrapTypeFromType(s.schema, arg.Type),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Directive{
|
return Directive{
|
||||||
|
2
vendor/github.com/99designs/gqlgen/graphql/version.go
generated
vendored
2
vendor/github.com/99designs/gqlgen/graphql/version.go
generated
vendored
@ -1,3 +1,3 @@
|
|||||||
package graphql
|
package graphql
|
||||||
|
|
||||||
const Version = "v0.9.1"
|
const Version = "v0.9.2"
|
||||||
|
7
vendor/github.com/99designs/gqlgen/handler/websocket.go
generated
vendored
7
vendor/github.com/99designs/gqlgen/handler/websocket.go
generated
vendored
@ -103,6 +103,7 @@ func (c *wsConnection) init() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.write(&operationMessage{Type: connectionAckMsg})
|
c.write(&operationMessage{Type: connectionAckMsg})
|
||||||
|
c.write(&operationMessage{Type: connectionKeepAliveMsg})
|
||||||
case connectionTerminateMsg:
|
case connectionTerminateMsg:
|
||||||
c.close(websocket.CloseNormalClosure, "terminated")
|
c.close(websocket.CloseNormalClosure, "terminated")
|
||||||
return false
|
return false
|
||||||
@ -279,9 +280,9 @@ func (c *wsConnection) sendData(id string, response *graphql.Response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *wsConnection) sendError(id string, errors ...*gqlerror.Error) {
|
func (c *wsConnection) sendError(id string, errors ...*gqlerror.Error) {
|
||||||
var errs []error
|
errs := make([]error, len(errors))
|
||||||
for _, err := range errors {
|
for i, err := range errors {
|
||||||
errs = append(errs, err)
|
errs[i] = err
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(errs)
|
b, err := json.Marshal(errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
9
vendor/github.com/99designs/gqlgen/internal/code/imports.go
generated
vendored
9
vendor/github.com/99designs/gqlgen/internal/code/imports.go
generated
vendored
@ -62,22 +62,23 @@ func ImportPathForDir(dir string) (res string) {
|
|||||||
modDir := dir
|
modDir := dir
|
||||||
assumedPart := ""
|
assumedPart := ""
|
||||||
for {
|
for {
|
||||||
f, err := ioutil.ReadFile(filepath.Join(modDir, "/", "go.mod"))
|
f, err := ioutil.ReadFile(filepath.Join(modDir, "go.mod"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// found it, stop searching
|
// found it, stop searching
|
||||||
return string(modregex.FindSubmatch(f)[1]) + assumedPart
|
return string(modregex.FindSubmatch(f)[1]) + assumedPart
|
||||||
}
|
}
|
||||||
|
|
||||||
assumedPart = "/" + filepath.Base(modDir) + assumedPart
|
assumedPart = "/" + filepath.Base(modDir) + assumedPart
|
||||||
modDir, err = filepath.Abs(filepath.Join(modDir, ".."))
|
parentDir, err := filepath.Abs(filepath.Join(modDir, ".."))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walked all the way to the root and didnt find anything :'(
|
if parentDir == modDir {
|
||||||
if modDir == "/" {
|
// Walked all the way to the root and didnt find anything :'(
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
modDir = parentDir
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, gopath := range gopaths {
|
for _, gopath := range gopaths {
|
||||||
|
9
vendor/github.com/99designs/gqlgen/internal/imports/prune.go
generated
vendored
9
vendor/github.com/99designs/gqlgen/internal/imports/prune.go
generated
vendored
@ -32,10 +32,7 @@ func Prune(filename string, src []byte) ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
unused, err := getUnusedImports(file, filename)
|
unused := getUnusedImports(file)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for ipath, name := range unused {
|
for ipath, name := range unused {
|
||||||
astutil.DeleteNamedImport(fset, file, name, ipath)
|
astutil.DeleteNamedImport(fset, file, name, ipath)
|
||||||
}
|
}
|
||||||
@ -49,7 +46,7 @@ func Prune(filename string, src []byte) ([]byte, error) {
|
|||||||
return imports.Process(filename, buf.Bytes(), &imports.Options{FormatOnly: true, Comments: true, TabIndent: true, TabWidth: 8})
|
return imports.Process(filename, buf.Bytes(), &imports.Options{FormatOnly: true, Comments: true, TabIndent: true, TabWidth: 8})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUnusedImports(file ast.Node, filename string) (map[string]string, error) {
|
func getUnusedImports(file ast.Node) map[string]string {
|
||||||
imported := map[string]*ast.ImportSpec{}
|
imported := map[string]*ast.ImportSpec{}
|
||||||
used := map[string]bool{}
|
used := map[string]bool{}
|
||||||
|
|
||||||
@ -99,5 +96,5 @@ func getUnusedImports(file ast.Node, filename string) (map[string]string, error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return unusedImport, nil
|
return unusedImport
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/99designs/gqlgen/plugin/modelgen/models.gotpl
generated
vendored
2
vendor/github.com/99designs/gqlgen/plugin/modelgen/models.gotpl
generated
vendored
@ -36,7 +36,7 @@
|
|||||||
{{- end}}
|
{{- end}}
|
||||||
|
|
||||||
{{ range $enum := .Enums }}
|
{{ range $enum := .Enums }}
|
||||||
{{ with .Description|go }} {{.|prefixLines "// "}} {{end}}
|
{{ with .Description }} {{.|prefixLines "// "}} {{end}}
|
||||||
type {{.Name|go }} string
|
type {{.Name|go }} string
|
||||||
const (
|
const (
|
||||||
{{- range $value := .Values}}
|
{{- range $value := .Values}}
|
||||||
|
Loading…
Reference in New Issue
Block a user