diff --git a/admin/src/components/reqlog/Search.tsx b/admin/src/components/reqlog/Search.tsx index 7c9c502..df681a4 100644 --- a/admin/src/components/reqlog/Search.tsx +++ b/admin/src/components/reqlog/Search.tsx @@ -89,7 +89,7 @@ function Search(): JSX.Element { FILTER, { onCompleted: (data) => { - setSearchExpr(data.httpRequestLogFilter.searchExpression || ""); + setSearchExpr(data.httpRequestLogFilter?.searchExpression || ""); }, } ); @@ -108,6 +108,7 @@ function Search(): JSX.Element { }, }); }, + onError: () => {}, }); const [ diff --git a/pkg/api/resolvers.go b/pkg/api/resolvers.go index ad04c3d..2e0da14 100644 --- a/pkg/api/resolvers.go +++ b/pkg/api/resolvers.go @@ -31,13 +31,7 @@ func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } func (r *queryResolver) HTTPRequestLogs(ctx context.Context) ([]HTTPRequestLog, error) { reqs, err := r.RequestLogService.FindRequests(ctx) if err == proj.ErrNoProject { - return nil, &gqlerror.Error{ - Path: graphql.GetPath(ctx), - Message: "No active project.", - Extensions: map[string]interface{}{ - "code": "no_active_project", - }, - } + return nil, noActiveProjectErr(ctx) } if err != nil { return nil, fmt.Errorf("could not query repository for requests: %v", err) @@ -268,7 +262,11 @@ func (r *mutationResolver) SetHTTPRequestLogFilter( if err != nil { return nil, fmt.Errorf("could not parse request log filter: %v", err) } - if err := r.RequestLogService.SetRequestLogFilter(ctx, filter); err != nil { + err = r.RequestLogService.SetRequestLogFilter(ctx, filter) + if err == proj.ErrNoProject { + return nil, noActiveProjectErr(ctx) + } + if err != nil { return nil, fmt.Errorf("could not set request log filter: %v", err) } @@ -331,3 +329,13 @@ func findReqFilterToHTTPReqLogFilter(findReqFilter reqlog.FindRequestsFilter) *H return httpReqLogFilter } + +func noActiveProjectErr(ctx context.Context) error { + return &gqlerror.Error{ + Path: graphql.GetPath(ctx), + Message: "No active project.", + Extensions: map[string]interface{}{ + "code": "no_active_project", + }, + } +}