graphql-flutter icon indicating copy to clipboard operation
graphql-flutter copied to clipboard

Allowing access to ConnectionState from GraphQLClient for Subscriptions

Open gouravd opened this issue 5 years ago • 5 comments

Is your feature request related to a problem? Please describe. We want to listen to GraphQL's subscriptions for onConnected, onDisconnected to show connection status. But connectionState is deep inside SocketClient class which is not directly exposed.

Describe the solution you'd like If we allow access to the Stream<ConnectionState> then we can listen to it and do client side operations based on connection status (connected/disconnected)

Describe alternatives you've considered None

Additional context None

gouravd avatar May 27 '20 11:05 gouravd

Just came here looking for the same thing, we have an app where we need to indicate to the user that the data is stale, would be great to have another value within the Subscription widget that contains the connection status.

gazzer82 avatar Aug 27 '20 11:08 gazzer82

This is highly needed!

RobertoOrtis avatar Oct 22 '20 15:10 RobertoOrtis

Same here, this would be really helpful. Is it on the roadmap?

alexasfb avatar Jan 07 '21 23:01 alexasfb

Would just exposing client connection state work here?

class WebSocketLink extends Link {
  //...
  Stream<SocketConnectionState> get connectionState => _socketClient.connectionState;
}

micimize avatar Jan 24 '21 21:01 micimize

One potential stop-gap for this is doing something like the following on the v4 beta:

    SocketClientConfig(
      onConnectOrReconnect: (socket) async {
        socket.stream.doOnError(...)
      },
    )

micimize avatar Jan 24 '21 21:01 micimize