apollographql / apollo-kotlin

:rocket:  A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform.
https://www.apollographql.com/docs/kotlin
MIT License
3.73k stars 654 forks source link

Open/Close web socket connection #2614

Open gayathri-nair03 opened 3 years ago

gayathri-nair03 commented 3 years ago

Im using Apollo Android Client v1.0.0 I see that you have exposed enableSubscriptions() and disableSubscriptions(). These internally open/close the web socket connection. Have you exposed any other methods (in v1.0.0) that let us open/close the web socket connection without having to worry about creating a subscription? Also, are there any such methods available in the latest version of Apollo Client (v2.3.1) ?

martinbonnin commented 3 years ago

Hi 👋 , Can you detail a bit more what you mean by "open/close the web socket connection without having to worry about creating a subscription" ? Why would you need other methods than enableSubscriptions()/disableSubscriptions() ?

gayathri-nair03 commented 3 years ago

I need to open the web socket connection open on app init, not on first subscription. This is so that we can avoid the sudden spike/surge in connection requests, say when millions of users land on a certain screen altogether (worst case scenario). So we want to make web socket connection on app init itself and then subscribe later on.

martinbonnin commented 3 years ago

Thanks for the explanation! I'm not aware of anything like this but I'm not super familiar with subscription code so don't take this as gospel. I'll keep looking.

tusharmath commented 3 years ago

Typically you would want to keep the transport separate from graphql. Web socket Connection lifecycle should be managed by the dev.