Skip to content

Commit

Permalink
Merge pull request #1288 from alexsn/nopath-field-noerror
Browse files Browse the repository at this point in the history
avoid computing field path when getting field errors
  • Loading branch information
lwc authored Aug 18, 2020
2 parents 108975c + fd0f97c commit e3ce560
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions graphql/context_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ func HasFieldError(ctx context.Context, rctx *FieldContext) bool {

c.errorsMu.Lock()
defer c.errorsMu.Unlock()
path := rctx.Path()

if len(c.errors) == 0 {
return false
}

path := rctx.Path()
for _, err := range c.errors {
if equalPath(err.Path, path) {
return true
Expand All @@ -83,8 +87,12 @@ func GetFieldErrors(ctx context.Context, rctx *FieldContext) gqlerror.List {

c.errorsMu.Lock()
defer c.errorsMu.Unlock()
path := rctx.Path()

if len(c.errors) == 0 {
return nil
}

path := rctx.Path()
var errs gqlerror.List
for _, err := range c.errors {
if equalPath(err.Path, path) {
Expand Down

0 comments on commit e3ce560

Please sign in to comment.