mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44: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:
65
vendor/github.com/99designs/gqlgen/api/generate.go
generated
vendored
65
vendor/github.com/99designs/gqlgen/api/generate.go
generated
vendored
@@ -6,25 +6,60 @@ import (
|
||||
"github.com/99designs/gqlgen/codegen"
|
||||
"github.com/99designs/gqlgen/codegen/config"
|
||||
"github.com/99designs/gqlgen/plugin"
|
||||
"github.com/99designs/gqlgen/plugin/federation"
|
||||
"github.com/99designs/gqlgen/plugin/modelgen"
|
||||
"github.com/99designs/gqlgen/plugin/resolvergen"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/tools/go/packages"
|
||||
)
|
||||
|
||||
func Generate(cfg *config.Config, option ...Option) error {
|
||||
_ = syscall.Unlink(cfg.Exec.Filename)
|
||||
_ = syscall.Unlink(cfg.Model.Filename)
|
||||
if cfg.Model.IsDefined() {
|
||||
_ = syscall.Unlink(cfg.Model.Filename)
|
||||
}
|
||||
|
||||
plugins := []plugin.Plugin{
|
||||
modelgen.New(),
|
||||
resolvergen.New(),
|
||||
plugins := []plugin.Plugin{}
|
||||
if cfg.Model.IsDefined() {
|
||||
plugins = append(plugins, modelgen.New())
|
||||
}
|
||||
plugins = append(plugins, resolvergen.New())
|
||||
if cfg.Federation.IsDefined() {
|
||||
plugins = append([]plugin.Plugin{federation.New()}, plugins...)
|
||||
}
|
||||
|
||||
for _, o := range option {
|
||||
o(cfg, &plugins)
|
||||
}
|
||||
|
||||
for _, p := range plugins {
|
||||
if inj, ok := p.(plugin.EarlySourceInjector); ok {
|
||||
if s := inj.InjectSourceEarly(); s != nil {
|
||||
cfg.Sources = append(cfg.Sources, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := cfg.LoadSchema(); err != nil {
|
||||
return errors.Wrap(err, "failed to load schema")
|
||||
}
|
||||
|
||||
for _, p := range plugins {
|
||||
if inj, ok := p.(plugin.LateSourceInjector); ok {
|
||||
if s := inj.InjectSourceLate(cfg.Schema); s != nil {
|
||||
cfg.Sources = append(cfg.Sources, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LoadSchema again now we have everything
|
||||
if err := cfg.LoadSchema(); err != nil {
|
||||
return errors.Wrap(err, "failed to load schema")
|
||||
}
|
||||
|
||||
if err := cfg.Init(); err != nil {
|
||||
return errors.Wrap(err, "generating core failed")
|
||||
}
|
||||
|
||||
for _, p := range plugins {
|
||||
if mut, ok := p.(plugin.ConfigMutator); ok {
|
||||
err := mut.MutateConfig(cfg)
|
||||
@@ -36,7 +71,7 @@ func Generate(cfg *config.Config, option ...Option) error {
|
||||
// Merge again now that the generated models have been injected into the typemap
|
||||
data, err := codegen.BuildData(cfg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "merging failed")
|
||||
return errors.Wrap(err, "merging type systems failed")
|
||||
}
|
||||
|
||||
if err = codegen.GenerateCode(data); err != nil {
|
||||
@@ -52,8 +87,14 @@ func Generate(cfg *config.Config, option ...Option) error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := validate(cfg); err != nil {
|
||||
return errors.Wrap(err, "validation failed")
|
||||
if err = codegen.GenerateCode(data); err != nil {
|
||||
return errors.Wrap(err, "generating core failed")
|
||||
}
|
||||
|
||||
if !cfg.SkipValidation {
|
||||
if err := validate(cfg); err != nil {
|
||||
return errors.Wrap(err, "validation failed")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -68,9 +109,11 @@ func validate(cfg *config.Config) error {
|
||||
if cfg.Resolver.IsDefined() {
|
||||
roots = append(roots, cfg.Resolver.ImportPath())
|
||||
}
|
||||
_, err := packages.Load(&packages.Config{Mode: packages.LoadTypes | packages.LoadSyntax}, roots...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "validation failed")
|
||||
|
||||
cfg.Packages.LoadAll(roots...)
|
||||
errs := cfg.Packages.Errors()
|
||||
if len(errs) > 0 {
|
||||
return errs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user