mirror of
https://github.com/stashapp/stash.git
synced 2025-12-15 21:03:22 +01:00
* Bump golang.org/x/text from 0.3.7 to 0.3.8 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.3.7...v0.3.8) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Update go dependencies * Update x/net --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
43 lines
1 KiB
Go
43 lines
1 KiB
Go
package gqlparser
|
|
|
|
import (
|
|
"github.com/vektah/gqlparser/v2/ast"
|
|
"github.com/vektah/gqlparser/v2/gqlerror"
|
|
"github.com/vektah/gqlparser/v2/parser"
|
|
"github.com/vektah/gqlparser/v2/validator"
|
|
_ "github.com/vektah/gqlparser/v2/validator/rules"
|
|
)
|
|
|
|
func LoadSchema(str ...*ast.Source) (*ast.Schema, error) {
|
|
return validator.LoadSchema(append([]*ast.Source{validator.Prelude}, str...)...)
|
|
}
|
|
|
|
func MustLoadSchema(str ...*ast.Source) *ast.Schema {
|
|
s, err := validator.LoadSchema(append([]*ast.Source{validator.Prelude}, str...)...)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return s
|
|
}
|
|
|
|
func LoadQuery(schema *ast.Schema, str string) (*ast.QueryDocument, gqlerror.List) {
|
|
query, err := parser.ParseQuery(&ast.Source{Input: str})
|
|
if err != nil {
|
|
gqlErr := err.(*gqlerror.Error)
|
|
return nil, gqlerror.List{gqlErr}
|
|
}
|
|
errs := validator.Validate(schema, query)
|
|
if errs != nil {
|
|
return nil, errs
|
|
}
|
|
|
|
return query, nil
|
|
}
|
|
|
|
func MustLoadQuery(schema *ast.Schema, str string) *ast.QueryDocument {
|
|
q, err := LoadQuery(schema, str)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return q
|
|
}
|