mercurius-js / mercurius

Implement GraphQL servers and gateways with Fastify
https://mercurius.dev/
MIT License
2.34k stars 234 forks source link

Should the defaultErrorFormatter output info logs? #912

Closed EDjur closed 1 year ago

EDjur commented 1 year ago

Hi and thanks for the great project!

I was recently looking into why all errors I throw are logged as info level and eventually stumbled upon this line in the default error formatter.

I might be misunderstanding something here, but wouldn't it make more sense for this to have error level logs?

I can of course override the behaviour by using my own custom formatter, but I'm just slightly hesitant to do so when all I need to replace is the log level of errors.

https://github.com/mercurius-js/mercurius/blob/32dc3183464e0d78c27c58ee7dec97405f671958/lib/errors.js#L58

mcollina commented 1 year ago

Those are graphql errors - mostly application from your own application. I wouldn't want to log those as Error because they are not really actionable for the developer.

EDjur commented 1 year ago

I suppose what I'm trying to achieve is something similar to this: https://github.com/mercurius-js/mercurius/issues/619

As it is useful for me to be able to look at graphql errors post-fact. The solution with the errorFormatter there seems simple enough. 👍

Thanks!