logging on gql errors
This commit is contained in:
parent
7253a9195d
commit
447a0647b2
@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/graph-gophers/dataloader"
|
"github.com/graph-gophers/dataloader"
|
||||||
"github.com/graphql-go/graphql"
|
"github.com/graphql-go/graphql"
|
||||||
|
"github.com/graphql-go/graphql/gqlerrors"
|
||||||
"github.com/graphql-go/handler"
|
"github.com/graphql-go/handler"
|
||||||
"github.com/minio/minio-go/v7"
|
"github.com/minio/minio-go/v7"
|
||||||
|
|
||||||
@ -23,6 +24,15 @@ func initHttp(resolveContext context.Context, schema graphql.Schema) error {
|
|||||||
Pretty: true,
|
Pretty: true,
|
||||||
GraphiQL: false,
|
GraphiQL: false,
|
||||||
Playground: true,
|
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) {
|
http.HandleFunc("/graphql", func(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user