express-graphql
express-graphql copied to clipboard
Error logging
I don't see any direct way to hook this up to an error logger. The formatError isn't really what I am looking as I cant connect the error to a request that way. I am thinking this must be an oversight on my part, as surely if one is running this in production, you would want to log errors. But I cant find any documentations or guides how todo this.
See my solution with formatError https://gist.github.com/nodkz/d7caf219dcb6e65b94900a9f549bf9d0
If the errors array has multiple items the solution with formatError will create multiple log entries for the same request. This is not desirable for log analytics.
Is there any better solution to this?
This is what I am doing:
graphqlHTTP({
schema: this.schema,
rootValue: this.rootValue,
graphiql: enableGraphiQL,
customFormatErrorFn: (error) => {
logger.warn(error.message, { error })
return formatError(error)
},
})
This library has been deprecated and this repo will be archived soon. It has been superseded by graphql-http.
Furthermore, if you seek a fully-featured, well-maintained and performant server - I heavily recommend GraphQL Yoga!