Hooking to the end of requests after throwing errors

Hello,

I am throwing errors within graphql-js validationRules and having a hard time catching theses afterwards in Apollo.

Apollo Server will, by default, treat thrown errors as HTTP 500.
I wanted to rewrite the HTTP code using an additional plugin here but without success.

I appears that after you thrown an error, even if it’s inside graphql-js, you won’t be triggering further hooks, especially one which should always be triggered willSendResponse.

If you mind why we are throwing instead of adding errors into the current context, you can refer to this issue #193.

So far, it seems to happens here apollo-server/runHttpQuery.ts at 655c1ca35514683fb6364519ec53846b86400042 · apollographql/apollo-server · GitHub,

validation errors not getting caught: apollo-server/requestPipeline.ts at 5188b1ee408b5e2a983662b0f3a15283c071e522 · apollographql/apollo-server · GitHub

Hey @c3b5aw, thanks for the helpful writeup. I’m pretty sure Apollo Server 4 handles exactly what you’re trying to accomplish with the plugin. We’re currently in alpha with an RC around the corner. Is updating to v4 an option for you?

The updated docs with relevant info are here:

Status code and headers can now be set by plugin (as well as resolvers and by your context function).

Hello @trevor.scheer,

This is not really doable as we are building a plugin orchestrator.