express-graphql icon indicating copy to clipboard operation
express-graphql copied to clipboard

Error logging

Open kaareal opened this issue 8 years ago • 5 comments

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.

kaareal avatar Feb 27 '17 14:02 kaareal

See my solution with formatError https://gist.github.com/nodkz/d7caf219dcb6e65b94900a9f549bf9d0

nodkz avatar Feb 28 '17 02:02 nodkz

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.

avicol avatar Jul 26 '18 07:07 avicol

Is there any better solution to this?

Smilebags avatar Jan 06 '21 14:01 Smilebags

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)
      },
    })

DiegoRBaquero avatar Jan 12 '22 17:01 DiegoRBaquero

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!

enisdenjo avatar Mar 20 '23 12:03 enisdenjo