diff --git a/internal/httpServer.go b/internal/httpServer.go index 4e96f49..6981b59 100644 --- a/internal/httpServer.go +++ b/internal/httpServer.go @@ -10,6 +10,7 @@ import ( "github.com/graph-gophers/dataloader" "github.com/graphql-go/graphql" + "github.com/graphql-go/graphql/gqlerrors" "github.com/graphql-go/handler" "github.com/minio/minio-go/v7" @@ -23,6 +24,15 @@ func initHttp(resolveContext context.Context, schema graphql.Schema) error { Pretty: true, GraphiQL: false, Playground: true, + FormatErrorFn: func(err error) gqlerrors.FormattedError { + switch err := err.(type) { + case gqlerrors.FormattedError: + log.Error("GQL: ", err.Message) + case *gqlerrors.Error: + log.Errorf("GQL: '%s' at '%v'", err.Message, err.Path) + } + return gqlerrors.FormatError(err) + }, }) http.HandleFunc("/graphql", func(rw http.ResponseWriter, r *http.Request) {