You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking for some direction on how to log graphql related errors while also adding relevant information from the req object. I'm able to log the error object using the serverOptions.formatError function but unable to access the req object from here.
serverOptions: {
formatError(err) {
logger.error({ err }); // looking to add userID here which is available from jwt token in request object
return err;
},
},
I don't believe the following snippet from service.js ever actually triggers the this.sendError function:
I think the issue here is that this.graphqlHandler is an async function. By returning without awaiting the catch block for this.sendError gets bypassed. I think this is fixed with return await this.graphqlHandler which should allow the catch block to remain in scope and be able to hit the this.sendError.
Can you try out that change and see if it does the trick for you?
I think that's part of the solution. The other issue is that the this.graphqlHandlerfunction in moleculerApollo.js has a try/catch block that doesn't rethrow the error and instead returns undefined when an error is caught. this.sendError is never triggered in service.js.
I'm looking for some direction on how to log graphql related errors while also adding relevant information from the req object. I'm able to log the error object using the serverOptions.formatError function but unable to access the req object from here.
I don't believe the following snippet from service.js ever actually triggers the
this.sendError
function:...because moleculerApollo.js swallows the error by returning
undefined
in the catch handler:The text was updated successfully, but these errors were encountered: