Fix panic print non json log line

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-03-23 23:44:33 +01:00
parent 39487ecc5f
commit 5d770c160c
4 changed files with 37 additions and 28 deletions

View File

@@ -15,7 +15,7 @@ resolver:
filename_template: "v1_resolver.go"
autobind: []
omit_panic_handler: true
# omit_panic_handler: true
call_argument_directives_with_null: true
models:

View File

@@ -101,32 +101,41 @@ func graphqlHandler(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg
)
srv := handler.New(es)
srv.AddTransport(transport.POST{})
srv.AddTransport(transport.MultipartForm{
MaxMemory: 32 * mb,
MaxUploadSize: 50 * mb,
})
srv.AddTransport(
transport.MultipartForm{
MaxMemory: 32 * mb,
MaxUploadSize: 50 * mb,
},
)
srv.Use(extension.Introspection{})
srv.SetRecoverFunc(
func(ctx context.Context, err any) error {
panic(fmt.Errorf("graphql resolver panic: %v", err))
},
)
srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
user := UserFromContext(ctx)
srv.AroundOperations(
func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
user := UserFromContext(ctx)
if user == nil {
return func(ctx context.Context) *graphql.Response {
return &graphql.Response{
Errors: gqlerror.List{
&gqlerror.Error{
Message: "authentication required",
Extensions: map[string]any{
"code": "UNAUTHENTICATED",
if user == nil {
return func(ctx context.Context) *graphql.Response {
return &graphql.Response{
Errors: gqlerror.List{
&gqlerror.Error{
Message: "authentication required",
Extensions: map[string]any{
"code": "UNAUTHENTICATED",
},
},
},
},
}
}
}
}
return next(ctx)
})
return next(ctx)
},
)
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()