Skip to content

Instantly share code, notes, and snippets.

@JosiasSena
Last active November 14, 2019 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosiasSena/0374df63512974da5cd9ec9b2869c5c9 to your computer and use it in GitHub Desktop.
Save JosiasSena/0374df63512974da5cd9ec9b2869c5c9 to your computer and use it in GitHub Desktop.
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