首页 > 解决方案 > AWS AppSync + Apollo Client ends up with a broken subscription websocket

问题描述

I'm having a problem with AppSync subscription. Together with my team we have created an app (TypeScript) and we are leveraging features of GraphQL via AWS AppSync. The problem we are having is that subscription breaks after network changes e.g. establishing VPN connection / changing network etc. The app page have to be refreshed manually to make it work again. This ends up with a stale state being shown in the app.

Can you please tell me whether using Apollo client with AppSync requires any extra setup to cover such a basic scenario? On Apollo's blog I noticed that AWS official client (AWS AppSync client) uses different protocol for subscriptions: https://www.apollographql.com/blog/community/aws-appsync-powered-by-apollo/ The fragment I'm referring to: "Instead of WebSockets, AppSync’s subscriptions use MQTT as the transport layer."

Please advice if using Apollo client is fine or should I migrate to AWS AppSync client. I'm using default Apollo client config, nothing custom.

Thanks!

标签: typescriptamazon-web-serviceswebsocketapollo-clientaws-appsync

解决方案


推荐阅读