Skip to content

Commit

Permalink
renamed GraphQLError to QueryError
Browse files Browse the repository at this point in the history
  • Loading branch information
neelance committed Oct 29, 2016
1 parent fcfa135 commit ffa9fea
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package errors

import "fmt"

type GraphQLError struct {
type QueryError struct {
Message string `json:"message"`
Locations []*Location `json:"locations,omitempty"`
}
Expand All @@ -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,
Expand All @@ -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 "<nil>"
}
Expand All @@ -39,4 +39,4 @@ func (err *GraphQLError) Error() string {
return fmt.Sprintf("graphql: %s", err.Message)
}

var _ error = &GraphQLError{}
var _ error = &QueryError{}
4 changes: 2 additions & 2 deletions graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ 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"`
}

func (s *Schema) Exec(ctx context.Context, queryString string, operationName string, variables map[string]interface{}) *Response {
document, err := query.Parse(queryString)
if err != nil {
return &Response{
Errors: []*errors.GraphQLError{err},
Errors: []*errors.QueryError{err},
}
}

Expand Down
10 changes: 5 additions & 5 deletions internal/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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{
Expand Down Expand Up @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
12 changes: 6 additions & 6 deletions internal/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit ffa9fea

Please sign in to comment.