首先仅获取所需的内容(RTK查询,GraphQl,React Native)
您将如何组合 /求解:RTK查询 / GraphQl的两种不同方法,
- 建议仅
- 删除该屏幕上的第一个功能上
在React Native App中
需要的内容?基本上,Apollo以及RTK Query建议有关小型查询,这些查询仅在获取与组件所需的数据相关的数据。这意味着只有在渲染时才存在所有数据,但是当用户没有互联网时会发生什么?
如果用户很长一段时间没有访问该屏幕,我们不希望用户看到过时的数据,因此我们希望在后台获取此屏幕,并且永远不要显示加载旋转器。当它们离线时,一切都应该尽可能最新和可用。
还应在恢复Internet访问时排队并执行突变。该应用基本上应该表现得好像根本没有连接问题。
因此,GraphQL订阅可能还可以,但是每个人都强烈建议您订阅任何东西。 GraphQl中的订阅听起来仍然很小,也只关心屏幕上屏幕上呈现的内容,并在屏幕上卸下时取消订阅。
在这一点上,这似乎是我的GraphQl抗模式,但是从用户角度来看,对于(React)本机应用程序是有意义的。您希望内容是最新的,因为它是一个应用程序,而不是一个网站,无论如何,许多数据都会被缓存,并且及时性并不重要。
How would you combine / solve the two diverging approaches of:
- rtk query / graphql advising to only fetch what is needed on that screen
- offline first capability
in a react native app?
Basically apollo and also rtk-query advise for small queries that are only fetching data that is relevant to what the component needs. This would mean that all data is only present when rendered, but what happens when the user does not have internet?
We don't want the user to see outdated data if they haven't visited that screen for a long time so we want to fetch this in the background and never show loading spinners. When they are offline everything should be as up to date as possible and usable.
Also mutations should be queued and performed when internet access is restored. The app should basically behave as if there is no connection issue at all.
So probably a graphql subscription would be ok but everyone strongly discourages to the subscribe-to-anything-pattern. Subscriptions in graphql still sound like they should be small and also only care about what is rendered on the screen and unsubscribe when the screen is unmounted.
At this point this whole seems like a graphql anti-pattern to me, but from a user perspective it makes sense for a (react) native app. You want stuff to be up to date because it is an app not a website where a lot of data is cached anyway and timeliness doesn't matter that much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论