mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 21:04:37 +03:00
Stash box client interface (#751)
* Add gql client generation files * Update dependencies * Add stash-box client generation to the makefile * Move scraped scene object matchers to models * Add stash-box to scrape with dropdown * Add scrape scene from fingerprint in UI
This commit is contained in:
67
vendor/github.com/99designs/gqlgen/codegen/directive.go
generated
vendored
67
vendor/github.com/99designs/gqlgen/codegen/directive.go
generated
vendored
@@ -7,15 +7,46 @@ import (
|
||||
|
||||
"github.com/99designs/gqlgen/codegen/templates"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/vektah/gqlparser/ast"
|
||||
"github.com/vektah/gqlparser/v2/ast"
|
||||
)
|
||||
|
||||
type DirectiveList map[string]*Directive
|
||||
|
||||
//LocationDirectives filter directives by location
|
||||
func (dl DirectiveList) LocationDirectives(location string) DirectiveList {
|
||||
return locationDirectives(dl, ast.DirectiveLocation(location))
|
||||
}
|
||||
|
||||
type Directive struct {
|
||||
*ast.DirectiveDefinition
|
||||
Name string
|
||||
Args []*FieldArgument
|
||||
Builtin bool
|
||||
}
|
||||
|
||||
//IsLocation check location directive
|
||||
func (d *Directive) IsLocation(location ...ast.DirectiveLocation) bool {
|
||||
for _, l := range d.Locations {
|
||||
for _, a := range location {
|
||||
if l == a {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func locationDirectives(directives DirectiveList, location ...ast.DirectiveLocation) map[string]*Directive {
|
||||
mDirectives := make(map[string]*Directive)
|
||||
for name, d := range directives {
|
||||
if d.IsLocation(location...) {
|
||||
mDirectives[name] = d
|
||||
}
|
||||
}
|
||||
return mDirectives
|
||||
}
|
||||
|
||||
func (b *builder) buildDirectives() (map[string]*Directive, error) {
|
||||
directives := make(map[string]*Directive, len(b.Schema.Directives))
|
||||
|
||||
@@ -24,11 +55,6 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) {
|
||||
return nil, errors.Errorf("directive with name %s already exists", name)
|
||||
}
|
||||
|
||||
var builtin bool
|
||||
if name == "skip" || name == "include" || name == "deprecated" {
|
||||
builtin = true
|
||||
}
|
||||
|
||||
var args []*FieldArgument
|
||||
for _, arg := range dir.Arguments {
|
||||
tr, err := b.Binder.TypeReference(arg.Type, nil)
|
||||
@@ -53,9 +79,10 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) {
|
||||
}
|
||||
|
||||
directives[name] = &Directive{
|
||||
Name: name,
|
||||
Args: args,
|
||||
Builtin: builtin,
|
||||
DirectiveDefinition: dir,
|
||||
Name: name,
|
||||
Args: args,
|
||||
Builtin: b.Config.Directives[name].SkipRuntime,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +119,10 @@ func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) {
|
||||
})
|
||||
}
|
||||
dirs[i] = &Directive{
|
||||
Name: d.Name,
|
||||
Args: args,
|
||||
Name: d.Name,
|
||||
Args: args,
|
||||
DirectiveDefinition: list[i].Definition,
|
||||
Builtin: b.Config.Directives[d.Name].SkipRuntime,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -119,18 +148,12 @@ func (d *Directive) CallArgs() string {
|
||||
return strings.Join(args, ", ")
|
||||
}
|
||||
|
||||
func (d *Directive) ResolveArgs(obj string, next string) string {
|
||||
args := []string{"ctx", obj, next}
|
||||
func (d *Directive) ResolveArgs(obj string, next int) string {
|
||||
args := []string{"ctx", obj, fmt.Sprintf("directive%d", next)}
|
||||
|
||||
for _, arg := range d.Args {
|
||||
dArg := "&" + arg.VarName
|
||||
if !arg.TypeReference.IsPtr() {
|
||||
if arg.Value != nil {
|
||||
dArg = templates.Dump(arg.Value)
|
||||
} else {
|
||||
dArg = templates.Dump(arg.Default)
|
||||
}
|
||||
} else if arg.Value == nil && arg.Default == nil {
|
||||
dArg := arg.VarName
|
||||
if arg.Value == nil && arg.Default == nil {
|
||||
dArg = "nil"
|
||||
}
|
||||
|
||||
@@ -144,7 +167,7 @@ func (d *Directive) Declaration() string {
|
||||
res := ucFirst(d.Name) + " func(ctx context.Context, obj interface{}, next graphql.Resolver"
|
||||
|
||||
for _, arg := range d.Args {
|
||||
res += fmt.Sprintf(", %s %s", arg.Name, templates.CurrentImports.LookupType(arg.TypeReference.GO))
|
||||
res += fmt.Sprintf(", %s %s", templates.ToGoPrivate(arg.Name), templates.CurrentImports.LookupType(arg.TypeReference.GO))
|
||||
}
|
||||
|
||||
res += ") (res interface{}, err error)"
|
||||
|
||||
Reference in New Issue
Block a user