diff --git a/graphql/context_response.go b/graphql/context_response.go index e0f3285fb05..340a4048cec 100644 --- a/graphql/context_response.go +++ b/graphql/context_response.go @@ -51,6 +51,9 @@ func AddErrorf(ctx context.Context, format string, args ...any) { // AddError sends an error to the client, first passing it through the error presenter. func AddError(ctx context.Context, err error) { + if err == nil { + return + } c := getResponseContext(ctx) presentedError := c.errorPresenter(ctx, ErrorOnPath(ctx, err)) diff --git a/graphql/error.go b/graphql/error.go index f816bef6b8e..bfcecd9a8d8 100644 --- a/graphql/error.go +++ b/graphql/error.go @@ -10,6 +10,9 @@ import ( type ErrorPresenterFunc func(ctx context.Context, err error) *gqlerror.Error func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error { + if err == nil { + return nil + } var gqlErr *gqlerror.Error if errors.As(err, &gqlErr) { return gqlErr