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:
WithoutPants
2020-09-17 19:57:18 +10:00
committed by GitHub
parent b0b5621337
commit 7a45943e8e
324 changed files with 34978 additions and 17323 deletions

View File

@@ -4,9 +4,10 @@ import (
"fmt"
"sort"
"github.com/99designs/gqlgen/codegen/config"
"github.com/pkg/errors"
"github.com/vektah/gqlparser/ast"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen/config"
)
// Data is a unified model of the code to be generated. Plugins may modify this structure to do things like implement
@@ -14,8 +15,7 @@ import (
type Data struct {
Config *config.Config
Schema *ast.Schema
SchemaStr map[string]string
Directives map[string]*Directive
Directives DirectiveList
Objects Objects
Inputs Objects
Interfaces map[string]*Interface
@@ -30,7 +30,6 @@ type Data struct {
type builder struct {
Config *config.Config
Schema *ast.Schema
SchemaStr map[string]string
Binder *config.Binder
Directives map[string]*Directive
}
@@ -38,26 +37,12 @@ type builder struct {
func BuildData(cfg *config.Config) (*Data, error) {
b := builder{
Config: cfg,
Schema: cfg.Schema,
}
b.Binder = b.Config.NewBinder()
var err error
b.Schema, b.SchemaStr, err = cfg.LoadSchema()
if err != nil {
return nil, err
}
err = cfg.Check()
if err != nil {
return nil, err
}
cfg.InjectBuiltins(b.Schema)
b.Binder, err = b.Config.NewBinder(b.Schema)
if err != nil {
return nil, err
}
b.Directives, err = b.buildDirectives()
if err != nil {
return nil, err
@@ -74,7 +59,6 @@ func BuildData(cfg *config.Config) (*Data, error) {
Config: cfg,
Directives: dataDirectives,
Schema: b.Schema,
SchemaStr: b.SchemaStr,
Interfaces: map[string]*Interface{},
}
@@ -96,7 +80,10 @@ func BuildData(cfg *config.Config) (*Data, error) {
s.Inputs = append(s.Inputs, input)
case ast.Union, ast.Interface:
s.Interfaces[schemaType.Name] = b.buildInterface(schemaType)
s.Interfaces[schemaType.Name], err = b.buildInterface(schemaType)
if err != nil {
return nil, errors.Wrap(err, "unable to bind to interface")
}
}
}
@@ -118,10 +105,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
@@ -131,6 +115,17 @@ func BuildData(cfg *config.Config) (*Data, error) {
return s.Inputs[i].Definition.Name < s.Inputs[j].Definition.Name
})
if b.Binder.SawInvalid {
// if we have a syntax error, show it
err := cfg.Packages.Errors()
if len(err) > 0 {
return nil, err
}
// otherwise show a generic error message
return nil, fmt.Errorf("invalid types were encountered while traversing the go source code, this probably means the invalid code generated isnt correct. add try adding -v to debug")
}
return &s, nil
}