func Do(p Params) *Result { source := source.NewSource(&source.Source{ Body: p.RequestString, Name: "GraphQL request", }) AST, err := parser.Parse(parser.ParseParams{Source: source}) if err != nil { return &Result{ Errors: gqlerrors.FormatErrors(err), } } validationResult := ValidateDocument(p.Schema, AST) if !validationResult.IsValid { return &Result{ Errors: validationResult.Errors, } } return Execute(ExecuteParams{ Schema: p.Schema, Root: p.RootObject, AST: AST, OperationName: p.OperationName, Args: p.VariableValues, }) }
func parse(t *testing.T, query string) *ast.Document { astDoc, err := parser.Parse(parser.ParseParams{ Source: query, Options: parser.ParseOptions{ NoLocation: true, }, }) if err != nil { t.Fatalf("Parse failed: %v", err) } return astDoc }
func TestParse(t *testing.T, query string) *ast.Document { astDoc, err := parser.Parse(parser.ParseParams{ Source: query, Options: parser.ParseOptions{ // include source, for error reporting NoSource: false, }, }) if err != nil { t.Fatalf("Parse failed: %v", err) } return astDoc }