Graphql-tools: GraphQL-tools cleanup

Created on 13 Jul 2018  路  3Comments  路  Source: ardatan/graphql-tools

Hey, I'm working with @JakeDawkins on cleaning up this repository a little bit, and going to use this issue to keep track of a checklist of some things we should do as part of that.

Ensure that all the features work well together:

Most helpful comment

@stubailo For example, if you have a resolver that throws an error but does not catch. If the logger option is not used then these errors would not be logged by the server anywhere. I've been relying on error logging via the logger option because I did not want to duplicate the catch, log, re-throw in every resolver.

With the current implementation, when the logger option is used, you at least are able to know something happened but it is not ideal because you lose a lot of the context. You get the original error message (prepended with Error in resolver Query.foo) and the stack trace but there may be other helpful bits that are lost, like an error code or a "request ID" (for correlating logs from frontend, graphql layer, and microservice backends).

I recently found out about https://github.com/prismagraphql/graphql-middleware, which seems like could be a simple solutiont for this kind of error logging. I'm not sure if you had something in mind that would be core to graphql-tools?

All 3 comments

@JakeDawkins @stubailo On the bullet point for deprecating logger option in makeExecutableSchema. It is kind of useful (but not totally because there is not really any context of the original error other than message) for logging errors that would normally be swallowed. Is there another recommended way to do that? Can it be done with graphql-extensions perhaps?

for logging errors that would normally be swallowed

Which errors are you referring to? Ideally, we can make it so that errors are just not swallowed anymore.

@stubailo For example, if you have a resolver that throws an error but does not catch. If the logger option is not used then these errors would not be logged by the server anywhere. I've been relying on error logging via the logger option because I did not want to duplicate the catch, log, re-throw in every resolver.

With the current implementation, when the logger option is used, you at least are able to know something happened but it is not ideal because you lose a lot of the context. You get the original error message (prepended with Error in resolver Query.foo) and the stack trace but there may be other helpful bits that are lost, like an error code or a "request ID" (for correlating logs from frontend, graphql layer, and microservice backends).

I recently found out about https://github.com/prismagraphql/graphql-middleware, which seems like could be a simple solutiont for this kind of error logging. I'm not sure if you had something in mind that would be core to graphql-tools?

Was this page helpful?
0 / 5 - 0 ratings