Last active
November 14, 2019 17:30
-
-
Save JosiasSena/d991ece6b4ccdbbb8a241baf6d813e5e to your computer and use it in GitHub Desktop.
Gists for https://medium.com/@josiassena/graphql-websocket-subscriptions-on-android-using-apollo-7e7311afdfca
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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