We are trying to start subscription in onCreate() method in MainActivity and we are able to connect to graphQL subscription which is connected successfully and giving proper response. Below is the code how we connect to graphQL subscription.
return ApolloClient.Builder()
.httpServerUrl("https://dqt-customer-test.azurewebsites.net/graphql")
.webSocketServerUrl("wss://dqt-customer-test.azurewebsites.net/graphql")
.webSocketReopenWhen { e, attempt ->
if (e is WebSocketReconnectException) {
true
} else {
attempt < 3
}
}
.build()
How to unsubscribe this WebSocket connection when I move to next screen.
we followed the Apollo Client Documentation for applying the subscription but for closing the connection we couldn’t find any method.