graphql-ws-client icon indicating copy to clipboard operation
graphql-ws-client copied to clipboard

Return a specific type from `streaming_operation`.

Open obmarg opened this issue 4 years ago • 1 comments

AsyncWebsocketClient::streaming_operation currently returns an anonymous Stream type. This is fine for reading the results of a subscription, but there's a few things it can't support:

  1. Stopping the subscription (arguably dropping the stream might do this, although not sure if it's handled very cleanly).
  2. Checking why a stream ended.

Ideally we'd return a custom type that implements Stream but also:

  1. Provides a stop function.
  2. Stops the subscription cleanly on drop.
  3. Provides a way to check whether the subscription stopped "cleanly" or because of some sort of connectivity error etc.

obmarg avatar Feb 14 '21 15:02 obmarg

There's a allow(dead_code) on the Message::Complete variant that can be removed once we have support for explicitly ending subscriptions.

obmarg avatar Feb 14 '21 16:02 obmarg