From b478cd1bcb4756b20f7f4b15fcf81f23e1a60a02 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Fri, 14 Sep 2018 12:40:31 +0200 Subject: graphql: update gqlgen to 0.5.1 fix #6 --- vendor/github.com/vektah/gqlparser/gqlparser.go | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 vendor/github.com/vektah/gqlparser/gqlparser.go (limited to 'vendor/github.com/vektah/gqlparser/gqlparser.go') diff --git a/vendor/github.com/vektah/gqlparser/gqlparser.go b/vendor/github.com/vektah/gqlparser/gqlparser.go new file mode 100644 index 00000000..71e46407 --- /dev/null +++ b/vendor/github.com/vektah/gqlparser/gqlparser.go @@ -0,0 +1,42 @@ +package gqlparser + +import ( + "github.com/vektah/gqlparser/ast" + "github.com/vektah/gqlparser/gqlerror" + "github.com/vektah/gqlparser/parser" + "github.com/vektah/gqlparser/validator" + _ "github.com/vektah/gqlparser/validator/rules" +) + +func LoadSchema(str ...*ast.Source) (*ast.Schema, *gqlerror.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 { + return nil, gqlerror.List{err} + } + 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 +} -- cgit