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
Update subscribe function to return a Promise of AsyncIterator or ExecutionResult (#918)
* Report or Reject when encountering Errors.
Currently the `subscribe()` function throws Errors, however this is awkward when used along with async functions which would expect a rejected iteration to represent failure. Also GraphQLErrors should be reported back to the client since they represent client-provided errors.
Updates test cases to represent this new behavior.
Includes a new utility `asyncIteratorReject`, and extends the behavior of `mapAsyncIterator` to help implement this.
* Subscriptions: Respond with error when failing to create source
If a subscribe resolve function throws or returns an error, that typically indicates an issue to be returned to the requesting client. This coerces errors into located GraphQLErrors so they are correctly reported.
* Subscriptions: Test source errors and execution errors.
After discussion in #868, decided that errors emitted from a source event stream should be considered "internal" errors and pass through.
However errors encountered during GraphQL execution on a source event should be considered "field" or "query" errors and be represented within that Response.
* Update subscribe signature to return a promise of AsyncIterator/Error/ExecutionResult
* Throw errors instead of returning them from Subscribe()
* Lint, refactor error mapper and add comments
* Report or Reject when encountering Errors.
Currently the `subscribe()` function throws Errors, however this is awkward when used along with async functions which would expect a rejected iteration to represent failure. Also GraphQLErrors should be reported back to the client since they represent client-provided errors.
Updates test cases to represent this new behavior.
Includes a new utility `asyncIteratorReject`, and extends the behavior of `mapAsyncIterator` to help implement this.
* Subscriptions: Respond with error when failing to create source
If a subscribe resolve function throws or returns an error, that typically indicates an issue to be returned to the requesting client. This coerces errors into located GraphQLErrors so they are correctly reported.
* Subscriptions: Test source errors and execution errors.
After discussion in #868, decided that errors emitted from a source event stream should be considered "internal" errors and pass through.
However errors encountered during GraphQL execution on a source event should be considered "field" or "query" errors and be represented within that Response.
* Update subscribe signature to return a promise of AsyncIterator/Error/ExecutionResult
* Throw errors instead of returning them from Subscribe()
* Lint, refactor error mapper and add comments
* Update test case assertions for stream errors to be more precise
* Add test case for wrong variable types
* Fix lint error (extra spaces)
* Fix multi-line doc block format
* Minor edits
* Trim trailing whitespace
0 commit comments