Skip to content

Commit

Permalink
avoid computing field path when getting field errors
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Snast <alexsn@fb.com>
  • Loading branch information
alexsn committed Aug 16, 2020
1 parent 08eee0f commit fd0f97c
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 fd0f97c

Please sign in to comment.