apollographql / subscriptions-transport-ws

:arrows_clockwise: A WebSocket client + server for GraphQL subscriptions
https://www.npmjs.com/package/subscriptions-transport-ws
MIT License
1.52k stars 342 forks source link

Throwing error in AsyncIterator does not produce standard GraphQL error #799

Closed flux627 closed 2 years ago

flux627 commented 4 years ago

Client tooling expects a payload with an errors array, however when an error is thrown inside a subscription's AsyncIterator, we get a websocket message that looks something like this:

{ "type": "error", "id": "1", "payload": { "name": "Error", "message": "Error thrown!" } }

When throwing in the subscription's resolve() method, we get the correct error structure.

This seems to be cause by this line. I would make a PR to fix, but this repository seems unmaintained. Once I get some kind of confirmation from maintainers that my time won't be wasted, I'll spend time on fixing this.