Skip to content

Instantly share code, notes, and snippets.

@JosiasSena
Last active November 14, 2019 17:30
Show Gist options
  • Save JosiasSena/d991ece6b4ccdbbb8a241baf6d813e5e to your computer and use it in GitHub Desktop.
Save JosiasSena/d991ece6b4ccdbbb8a241baf6d813e5e to your computer and use it in GitHub Desktop.
class GraphQLApi(private val sharedOkHttpClientBuilder: OkHttpClient.Builder) {
// ...
fun <D : Operation.Data, V : Operation.Variables> subscribe(subscription: Subscription<D, D, V>): Flowable<Response<D>> {
// Create our dedicated apollo client
val apolloClient = ApolloSubscriptionClientFactory(sharedOkHttpClientBuilder)
.createSubscriptionApolloClient()
// Perform the actual subscription
val call = apolloClient.subscribe(subscription)
// Subscribe using Rx2Apollo
return Rx2Apollo.from<D>(call)
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment