Skip to content

Commit a501eb0

Browse files
committed
If we crafted a GraphQL Error in our Resolver code, don't mess with it,
return it untouched.
1 parent 25614ea commit a501eb0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

internal/exec/subscribe.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ func (r *Request) Subscribe(ctx context.Context, s *resolvable.Schema, op *query
112112

113113
if subErr, ok := resp.Interface().(errors.SubscriptionError); ok {
114114
if err := subErr.SubscriptionError(); err != nil {
115-
c <- &Response{Errors: []*errors.QueryError{errors.Errorf("%s", err)}}
115+
if gqlError, ok := err.(*errors.QueryError); ok {
116+
c <- &Response{Errors: []*errors.QueryError{gqlError}}
117+
} else {
118+
c <- &Response{Errors: []*errors.QueryError{errors.Errorf("%s", err)}}
119+
}
116120
return
117121
}
118122
}

subscriptions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package graphql
33
import (
44
"context"
55
"errors"
6+
67
qerrors "github.com/graph-gophers/graphql-go/errors"
78
"github.com/graph-gophers/graphql-go/internal/common"
89
"github.com/graph-gophers/graphql-go/internal/exec"

0 commit comments

Comments
 (0)