Hooks formatResponse and formatError do not accept async operations.
Tools that report errors are difficult to use because formatError does not support async operations.
I particularly need to perform some operations with each graphql response, I can not because formatResponse is not async.
I'm doing tests and adjustments and I intend to send a PR soon, before I'm starting a dialogue about it.
Related #1748
I'm running into an issue with with AWS Lambda. I am sending my error to sentry inside formatError but this is an asynchronous operation so there is a chance that the function will close before the message is sent.
Same!
Same
Same. I need some data from cache or db to decorate response. How can I do it without async support?!
Any workaround for this? I need to make an http call (apollo-rest-datasource) under certain conditions before returning response (formatResponse).
Couldn't find any other Apollo Server function that executes after all resolvers are resolved.
I actually am using Sentry too to report any error occuring in formatError function, but errors are generally sent so I didn't except to have a problem with this until reading this issue.
@vinicius73 any news here? I am facing the same issue...
@dunika My problem is exactly the same, using a very similar stack. Were you able to solve it?
This should be possible by using the new request pipeline plugin API. willSendResponse can be async and will allow you to modify the response. For error reporting, didEncounterErrors (https://github.com/apollographql/apollo-server/pull/2719) is the hook to use.
@martijnwalraven I can't find anything in the docs any of this. Has this been released?
Do you have an example of where/how the didEncounterErrors hook is used?
@bertero Sorry for the late response I havn't implemented any solution for this but you could use graphql-middleware](https://github.com/prisma/graphql-middleware) to do I I'd say
@dunika Docs seem to be still WIP, I found a preview here:
https://github.com/apollographql/apollo-server/blob/abernix/docs-plugins/docs/source/features/plugins.md
and here is the example of using the hook:
https://github.com/apollographql/apollo-server/issues/1709#issuecomment-495793375
Most helpful comment
@dunika Docs seem to be still WIP, I found a preview here:
https://github.com/apollographql/apollo-server/blob/abernix/docs-plugins/docs/source/features/plugins.md
and here is the example of using the
hook:https://github.com/apollographql/apollo-server/issues/1709#issuecomment-495793375