Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class ApolloSubscriptionClientFactory {
fun createSubscriptionApolloClient(sharedOkHttpClientBuilder: OkHttpClient.Builder): ApolloClient {
val okHttpClient = sharedOkHttpClientBuilder
.pingInterval(KEEP_ALIVE_INTERVAL, TimeUnit.SECONDS)
.build()
val subscriptionTransportFactory = WebSocketSubscriptionTransport.Factory("wss://your_subscription_host/graphql", okHttpClient)
return ApolloClient.builder()
.serverUrl("https://your_host_url/graphql")
.okHttpClient(okHttpClient)
.subscriptionConnectionParams(HeadersProvider.HEADERS)
.subscriptionTransportFactory(subscriptionTransportFactory)
.build()
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment