【发布时间】:2021-11-23 09:34:19
【问题描述】:
应用程序中有几个地方在不同的突变后重新获取特定查询。
例子:
// Some component
const [setUserLocation, setUserLocationResult] = useMutation(setUserLocationMutation, {
refetchQueries: [{ query: getRecommendationsQuery }],
});
在我的RecommendationsComponent 中,我想知道这个查询正在加载,但是useQuery 的loading 在重新获取getRecommendationsQuery 时不会更新。
const {
data,
loading, // this loading is false all the time except first loading
} = useQuery(getRecommendationsQuery);
我可以尝试将useQuery 的refetch 放到上下文中并在任何地方使用它而不是refetchQueries 道具,但是有没有更好的方法来实现这一点而没有那个肮脏的黑客 - 要么让loading 工作,要么使用 apollo 客户端订阅该信息?
【问题讨论】:
标签: javascript reactjs apollo apollo-client