Using Apollo subscriptions for first time so could...
# apollo-kotlin
j
Using Apollo subscriptions for first time so could easily be issue on my side but am getting
java.net.ProtocolException: Expected HTTP 101 response but was '404 Not Found
for some reason even though subscription seems to work in playground....more in thread....
I've hosted graphql backend at https://peopleinspace-graphql-guhrsfr7ka-uc.a.run.app/playground which supports for example
Copy code
subscription {
  issPosition {
    latitude
    longitude
  }
}
and calling following (in shared KMP code)
Copy code
override fun pollISSPosition(): Flow<IssPosition> {
        return apolloClient.subscription(IssPositionSubscription()).toFlow().map {
            val result = it.dataAssertNoErrors.issPosition
            IssPosition(result.latitude, result.longitude)
        }
    }
have pushed changes made so far to following branch....error occurs when for example clicking map option in android client https://github.com/joreilly/PeopleInSpace/tree/graphql_client
and this is what I see in playground
I'll keep digging but just in case any particular things to look out for
b
maybe it’s a matter of setting
webSocketServerUrl
but not sure what the right value needs to be
j
ah, didn't realise that needed to be set....let me try setting it
b
I think
<wss://peopleinspace-graphql-guhrsfr7ka-uc.a.run.app/subscriptions>
j
that was it, thanks!
also just updated that branch with the change
b
yay 🎉
j
btw feel free if you want to use this as an example of public graphql backend that supports subscriptions.....hopefully won't cost too much to run and I have yearly google cloud credits which I haven't been putting to use anyway 🙂
b
very cool 🙏 That could prove useful 😄
j
I ended up creating new repo for the source for it https://github.com/joreilly/PeopleInSpaceGraphQLServer
👍 1
💜 1