From ffa9fea4d939e28562475e1beac0826176fd64fc Mon Sep 17 00:00:00 2001 From: Richard Musiol Date: Sat, 29 Oct 2016 17:56:05 +0200 Subject: [PATCH] renamed GraphQLError to QueryError --- errors/errors.go | 14 +++++++------- graphql.go | 4 ++-- internal/exec/exec.go | 10 +++++----- internal/exec/introspection.go | 4 ++-- internal/lexer/lexer.go | 2 +- internal/query/query.go | 2 +- internal/schema/schema.go | 12 ++++++------ 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/errors/errors.go b/errors/errors.go index 437d3fa5a9..ea71bbb160 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -2,7 +2,7 @@ package errors import "fmt" -type GraphQLError struct { +type QueryError struct { Message string `json:"message"` Locations []*Location `json:"locations,omitempty"` } @@ -12,14 +12,14 @@ type Location struct { Column int `json:"column"` } -func Errorf(format string, a ...interface{}) *GraphQLError { - return &GraphQLError{ +func Errorf(format string, a ...interface{}) *QueryError { + return &QueryError{ Message: fmt.Sprintf(format, a...), } } -func ErrorfWithLoc(line int, column int, format string, a ...interface{}) *GraphQLError { - return &GraphQLError{ +func ErrorfWithLoc(line int, column int, format string, a ...interface{}) *QueryError { + return &QueryError{ Message: fmt.Sprintf(format, a...), Locations: []*Location{{ Line: line, @@ -28,7 +28,7 @@ func ErrorfWithLoc(line int, column int, format string, a ...interface{}) *Graph } } -func (err *GraphQLError) Error() string { +func (err *QueryError) Error() string { if err == nil { return "" } @@ -39,4 +39,4 @@ func (err *GraphQLError) Error() string { return fmt.Sprintf("graphql: %s", err.Message) } -var _ error = &GraphQLError{} +var _ error = &QueryError{} diff --git a/graphql.go b/graphql.go index 89b692b4ea..30044e26eb 100644 --- a/graphql.go +++ b/graphql.go @@ -34,7 +34,7 @@ func ParseSchema(schemaString string, resolver interface{}) (*Schema, error) { type Response struct { Data interface{} `json:"data,omitempty"` - Errors []*errors.GraphQLError `json:"errors,omitempty"` + Errors []*errors.QueryError `json:"errors,omitempty"` Extensions map[string]interface{} `json:"extensions,omitempty"` } @@ -42,7 +42,7 @@ func (s *Schema) Exec(ctx context.Context, queryString string, operationName str document, err := query.Parse(queryString) if err != nil { return &Response{ - Errors: []*errors.GraphQLError{err}, + Errors: []*errors.QueryError{err}, } } diff --git a/internal/exec/exec.go b/internal/exec/exec.go index b4fea9a7d3..227f7ad8e8 100644 --- a/internal/exec/exec.go +++ b/internal/exec/exec.go @@ -375,10 +375,10 @@ type request struct { vars map[string]interface{} schema *schema.Schema mu sync.Mutex - errs []*errors.GraphQLError + errs []*errors.QueryError } -func (r *request) addError(err *errors.GraphQLError) { +func (r *request) addError(err *errors.QueryError) { r.mu.Lock() r.errs = append(r.errs, err) r.mu.Unlock() @@ -396,10 +396,10 @@ func (r *request) handlePanic() { } } -func ExecuteRequest(ctx context.Context, e *Exec, document *query.Document, operationName string, variables map[string]interface{}) (interface{}, []*errors.GraphQLError) { +func ExecuteRequest(ctx context.Context, e *Exec, document *query.Document, operationName string, variables map[string]interface{}) (interface{}, []*errors.QueryError) { op, err := getOperation(document, operationName) if err != nil { - return nil, []*errors.GraphQLError{err} + return nil, []*errors.QueryError{err} } r := &request{ @@ -427,7 +427,7 @@ func ExecuteRequest(ctx context.Context, e *Exec, document *query.Document, oper return data, r.errs } -func getOperation(document *query.Document, operationName string) (*query.Operation, *errors.GraphQLError) { +func getOperation(document *query.Document, operationName string) (*query.Operation, *errors.QueryError) { if len(document.Operations) == 0 { return nil, errors.Errorf("no operations in query document") } diff --git a/internal/exec/introspection.go b/internal/exec/introspection.go index f467982750..341e40e1b7 100644 --- a/internal/exec/introspection.go +++ b/internal/exec/introspection.go @@ -19,7 +19,7 @@ var typeExec iExec func init() { { - var err *errors.GraphQLError + var err *errors.QueryError metaSchema, err = schema.Parse(metaSchemaSrc) if err != nil { panic(err) @@ -465,7 +465,7 @@ func (r *directiveResolver) Args() []*inputValueResolver { var introspectionQuery *query.Document func init() { - var err *errors.GraphQLError + var err *errors.QueryError introspectionQuery, err = query.Parse(introspectionQuerySrc) if err != nil { panic(err) diff --git a/internal/lexer/lexer.go b/internal/lexer/lexer.go index 1696f730bb..76c02e3d03 100644 --- a/internal/lexer/lexer.go +++ b/internal/lexer/lexer.go @@ -21,7 +21,7 @@ func New(sc *scanner.Scanner) *Lexer { return l } -func (l *Lexer) CatchSyntaxError(f func()) (errRes *errors.GraphQLError) { +func (l *Lexer) CatchSyntaxError(f func()) (errRes *errors.QueryError) { defer func() { if err := recover(); err != nil { if err, ok := err.(syntaxError); ok { diff --git a/internal/query/query.go b/internal/query/query.go index ee1c7edfbc..7f1c3898d2 100644 --- a/internal/query/query.go +++ b/internal/query/query.go @@ -79,7 +79,7 @@ func (Field) isSelection() {} func (FragmentSpread) isSelection() {} func (InlineFragment) isSelection() {} -func Parse(queryString string) (doc *Document, err *errors.GraphQLError) { +func Parse(queryString string) (doc *Document, err *errors.QueryError) { sc := &scanner.Scanner{ Mode: scanner.ScanIdents | scanner.ScanInts | scanner.ScanFloats | scanner.ScanStrings, } diff --git a/internal/schema/schema.go b/internal/schema/schema.go index 2b0d8fa34e..b4ede512c8 100644 --- a/internal/schema/schema.go +++ b/internal/schema/schema.go @@ -88,7 +88,7 @@ type InputValue struct { Default interface{} } -func Parse(schemaString string) (s *Schema, err *errors.GraphQLError) { +func Parse(schemaString string) (s *Schema, err *errors.QueryError) { sc := &scanner.Scanner{ Mode: scanner.ScanIdents | scanner.ScanInts | scanner.ScanFloats | scanner.ScanStrings, } @@ -153,8 +153,8 @@ func Parse(schemaString string) (s *Schema, err *errors.GraphQLError) { return s, nil } -func resolveType(s *Schema, t common.Type) *errors.GraphQLError { - var err *errors.GraphQLError +func resolveType(s *Schema, t common.Type) *errors.QueryError { + var err *errors.QueryError switch t := t.(type) { case *Scalar: // nothing @@ -197,8 +197,8 @@ func resolveType(s *Schema, t common.Type) *errors.GraphQLError { return nil } -func resolveField(s *Schema, f *Field) *errors.GraphQLError { - var err *errors.GraphQLError +func resolveField(s *Schema, f *Field) *errors.QueryError { + var err *errors.QueryError f.Type, err = resolveTypeName(s, f.Type) if err != nil { return err @@ -207,7 +207,7 @@ func resolveField(s *Schema, f *Field) *errors.GraphQLError { return nil } -func resolveTypeName(s *Schema, t common.Type) (common.Type, *errors.GraphQLError) { +func resolveTypeName(s *Schema, t common.Type) (common.Type, *errors.QueryError) { if name, ok := t.(*common.TypeName); ok { refT, ok := s.Types[name.Name] if !ok {