envelop icon indicating copy to clipboard operation
envelop copied to clipboard

Plugin API: Allow to short-circuit and fall back to `ExecutionResult`

Open dotansimha opened this issue 4 years ago • 1 comments

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:

  • parse do short-circuit with the parsing error
  • validate skipped (0 errors)
  • contextFactory skipped
  • rootValue skipped
  • execute is not being called and returns the parsing error from parse phase 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.

dotansimha avatar Jul 02 '21 07:07 dotansimha

@n1ru4l thoughts?

dotansimha avatar Jul 02 '21 07:07 dotansimha