envelop
envelop copied to clipboard
Plugin API: Allow to short-circuit and fall back to `ExecutionResult`
I think maybe we can have an API that allow phases that happens before execute to do short-circuit and then other steps and being skipped and execute returns ExecutionResult with the custom error.
For example:
-
parsedo short-circuit with the parsing error -
validateskipped (0 errors) -
contextFactoryskipped -
rootValueskipped -
executeis not being called and returns the parsing error fromparsephase as{ data: undefined, errors: [THE_ERROR] }
Rough draft: https://github.com/dotansimha/envelop/pull/358
This should allow developers to intercept parse/validate errors using useErorrHandler and similar plugins, and also simplify some aspects of the request pipeline.
@n1ru4l thoughts?