When we had initially set up Apollo, we used just the network transport. But subscriptions is an advanced use case which needs more configuration. So we have to use ApolloWebSocket.

Now we need to update our ApolloClient instance to point to the subscription server.

Open Network.kt and update the following:

+ private val GRAPHQL_WEBSOCKET_ENDPOINT: String = "wss://"
apolloClient = ApolloClient.builder()
.normalizedCache(normalizedCacheFactory, cacheKeyResolver)
+ .subscriptionTransportFactory(WebSocketSubscriptionTransport.Factory(GRAPHQL_WEBSOCKET_ENDPOINT, okHttpClient))
.addCustomTypeAdapter(CustomType.TIMESTAMPTZ, dateCustomTypeAdapter)

Note that we have added a new subscriptionTransportFactory with GRAPHQL_WEBSOCKET_ENDPOINT and hence all GraphQL subscription queries can go through a websocket connection.