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 {
|
||||
arg{{$i}} = data
|
||||
{{- if $arg.TypeReference.IsNilable }}
|
||||
} else if tmp == nil {
|
||||
arg{{$i}} = nil
|
||||
{{- end }}
|
||||
} else {
|
||||
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/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...)
|
||||
|
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
|
||||
}
|
||||
|
||||
s.ReferencedTypes, err = b.buildTypes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.ReferencedTypes = b.buildTypes()
|
||||
|
||||
sort.Slice(s.Objects, func(i, j int) bool {
|
||||
return s.Objects[i].Definition.Name < s.Objects[j].Definition.Name
|
||||
|
12
vendor/github.com/99designs/gqlgen/codegen/field.go
generated
vendored
12
vendor/github.com/99designs/gqlgen/codegen/field.go
generated
vendored
@ -384,16 +384,16 @@ func (f *Field) ComplexitySignature() string {
|
||||
}
|
||||
|
||||
func (f *Field) ComplexityArgs() string {
|
||||
var args []string
|
||||
for _, arg := range f.Args {
|
||||
args = append(args, "args["+strconv.Quote(arg.Name)+"].("+templates.CurrentImports.LookupType(arg.TypeReference.GO)+")")
|
||||
args := make([]string, len(f.Args))
|
||||
for i, arg := range f.Args {
|
||||
args[i] = "args[" + strconv.Quote(arg.Name) + "].(" + templates.CurrentImports.LookupType(arg.TypeReference.GO) + ")"
|
||||
}
|
||||
|
||||
return strings.Join(args, ", ")
|
||||
}
|
||||
|
||||
func (f *Field) CallArgs() string {
|
||||
var args []string
|
||||
args := make([]string, 0, len(f.Args)+2)
|
||||
|
||||
if f.IsResolver {
|
||||
args = append(args, "rctx")
|
||||
@ -401,11 +401,9 @@ func (f *Field) CallArgs() string {
|
||||
if !f.Object.Root {
|
||||
args = append(args, "obj")
|
||||
}
|
||||
} else {
|
||||
if f.MethodHasContext {
|
||||
} else if f.MethodHasContext {
|
||||
args = append(args, "ctx")
|
||||
}
|
||||
}
|
||||
|
||||
for _, arg := range f.Args {
|
||||
args = append(args, "args["+strconv.Quote(arg.Name)+"].("+templates.CurrentImports.LookupType(arg.TypeReference.GO)+")")
|
||||
|
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 {
|
||||
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)
|
||||
{{- else -}}
|
||||
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 {
|
||||
it.{{$field.GoFieldName}} = data
|
||||
{{- if $field.TypeReference.IsNilable }}
|
||||
} else if tmp == nil {
|
||||
it.{{$field.GoFieldName}} = nil
|
||||
{{- end }}
|
||||
} else {
|
||||
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
|
||||
}
|
||||
for i := 0; i < o.Type.(*types.Named).NumMethods(); i++ {
|
||||
switch o.Type.(*types.Named).Method(i).Name() {
|
||||
case "UnmarshalGQL":
|
||||
if o.Type.(*types.Named).Method(i).Name() == "UnmarshalGQL" {
|
||||
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"
|
||||
"go/types"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/99designs/gqlgen/internal/code"
|
||||
)
|
||||
@ -20,7 +21,7 @@ type Imports struct {
|
||||
}
|
||||
|
||||
func (i *Import) String() string {
|
||||
if i.Alias == i.Name {
|
||||
if strings.HasSuffix(i.Path, i.Alias) {
|
||||
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
|
||||
wordWalker(name, func(info *wordInfo) {
|
||||
word := info.Word
|
||||
if first {
|
||||
switch {
|
||||
case first:
|
||||
if strings.ToUpper(word) == word || strings.ToLower(word) == word {
|
||||
// ID → id, CAMEL → camel
|
||||
word = strings.ToLower(info.Word)
|
||||
@ -294,9 +295,9 @@ func ToGoPrivate(name string) string {
|
||||
word = lcFirst(info.Word)
|
||||
}
|
||||
first = false
|
||||
} else if info.MatchCommonInitial {
|
||||
case info.MatchCommonInitial:
|
||||
word = strings.ToUpper(word)
|
||||
} else if !info.HasCommonInitial {
|
||||
case !info.HasCommonInitial:
|
||||
word = ucFirst(strings.ToLower(word))
|
||||
}
|
||||
runes = append(runes, []rune(word)...)
|
||||
@ -319,9 +320,10 @@ func wordWalker(str string, f func(*wordInfo)) {
|
||||
hasCommonInitial := false
|
||||
for i+1 <= len(runes) {
|
||||
eow := false // whether we hit the end of a word
|
||||
if i+1 == len(runes) {
|
||||
switch {
|
||||
case i+1 == len(runes):
|
||||
eow = true
|
||||
} else if isDelimiter(runes[i+1]) {
|
||||
case isDelimiter(runes[i+1]):
|
||||
// underscore; shift the remainder forward over any run of underscores
|
||||
eow = true
|
||||
n := 1
|
||||
@ -336,7 +338,7 @@ func wordWalker(str string, f func(*wordInfo)) {
|
||||
|
||||
copy(runes[i+1:], runes[i+n+1:])
|
||||
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
|
||||
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"
|
||||
)
|
||||
|
||||
func (b *builder) buildTypes() (map[string]*config.TypeReference, error) {
|
||||
func (b *builder) buildTypes() map[string]*config.TypeReference {
|
||||
ret := map[string]*config.TypeReference{}
|
||||
|
||||
for _, ref := range b.Binder.References {
|
||||
@ -14,5 +14,5 @@ func (b *builder) buildTypes() (map[string]*config.TypeReference, error) {
|
||||
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 {
|
||||
var types []Type
|
||||
types := make([]Type, 0, len(s.schema.Types))
|
||||
for _, typ := range s.schema.Types {
|
||||
if strings.HasPrefix(typ.Name, "__") {
|
||||
continue
|
||||
@ -34,7 +34,7 @@ func (s *Schema) SubscriptionType() *Type {
|
||||
}
|
||||
|
||||
func (s *Schema) Directives() []Directive {
|
||||
var res []Directive
|
||||
res := make([]Directive, 0, len(s.schema.Directives))
|
||||
|
||||
for _, d := range s.schema.Directives {
|
||||
res = append(res, s.directiveFromDef(d))
|
||||
@ -44,19 +44,19 @@ func (s *Schema) Directives() []Directive {
|
||||
}
|
||||
|
||||
func (s *Schema) directiveFromDef(d *ast.DirectiveDefinition) Directive {
|
||||
var locs []string
|
||||
for _, loc := range d.Locations {
|
||||
locs = append(locs, string(loc))
|
||||
locs := make([]string, len(d.Locations))
|
||||
for i, loc := range d.Locations {
|
||||
locs[i] = string(loc)
|
||||
}
|
||||
|
||||
var args []InputValue
|
||||
for _, arg := range d.Arguments {
|
||||
args = append(args, InputValue{
|
||||
args := make([]InputValue, len(d.Arguments))
|
||||
for i, arg := range d.Arguments {
|
||||
args[i] = InputValue{
|
||||
Name: arg.Name,
|
||||
Description: arg.Description,
|
||||
DefaultValue: defaultValue(arg.DefaultValue),
|
||||
Type: WrapTypeFromType(s.schema, arg.Type),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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: connectionKeepAliveMsg})
|
||||
case connectionTerminateMsg:
|
||||
c.close(websocket.CloseNormalClosure, "terminated")
|
||||
return false
|
||||
@ -279,9 +280,9 @@ func (c *wsConnection) sendData(id string, response *graphql.Response) {
|
||||
}
|
||||
|
||||
func (c *wsConnection) sendError(id string, errors ...*gqlerror.Error) {
|
||||
var errs []error
|
||||
for _, err := range errors {
|
||||
errs = append(errs, err)
|
||||
errs := make([]error, len(errors))
|
||||
for i, err := range errors {
|
||||
errs[i] = err
|
||||
}
|
||||
b, err := json.Marshal(errs)
|
||||
if err != nil {
|
||||
|
7
vendor/github.com/99designs/gqlgen/internal/code/imports.go
generated
vendored
7
vendor/github.com/99designs/gqlgen/internal/code/imports.go
generated
vendored
@ -62,22 +62,23 @@ func ImportPathForDir(dir string) (res string) {
|
||||
modDir := dir
|
||||
assumedPart := ""
|
||||
for {
|
||||
f, err := ioutil.ReadFile(filepath.Join(modDir, "/", "go.mod"))
|
||||
f, err := ioutil.ReadFile(filepath.Join(modDir, "go.mod"))
|
||||
if err == nil {
|
||||
// found it, stop searching
|
||||
return string(modregex.FindSubmatch(f)[1]) + assumedPart
|
||||
}
|
||||
|
||||
assumedPart = "/" + filepath.Base(modDir) + assumedPart
|
||||
modDir, err = filepath.Abs(filepath.Join(modDir, ".."))
|
||||
parentDir, err := filepath.Abs(filepath.Join(modDir, ".."))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if parentDir == modDir {
|
||||
// Walked all the way to the root and didnt find anything :'(
|
||||
if modDir == "/" {
|
||||
break
|
||||
}
|
||||
modDir = parentDir
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
unused, err := getUnusedImports(file, filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
unused := getUnusedImports(file)
|
||||
for ipath, name := range unused {
|
||||
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})
|
||||
}
|
||||
|
||||
func getUnusedImports(file ast.Node, filename string) (map[string]string, error) {
|
||||
func getUnusedImports(file ast.Node) map[string]string {
|
||||
imported := map[string]*ast.ImportSpec{}
|
||||
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}}
|
||||
|
||||
{{ range $enum := .Enums }}
|
||||
{{ with .Description|go }} {{.|prefixLines "// "}} {{end}}
|
||||
{{ with .Description }} {{.|prefixLines "// "}} {{end}}
|
||||
type {{.Name|go }} string
|
||||
const (
|
||||
{{- range $value := .Values}}
|
||||
|
Loading…
Reference in New Issue
Block a user