如何从客户端重试graphQl查询

时间:2021-07-30 05:27:52

标签: reactjs graphql apollo-client apollo-server

概述:

const [getData, {loading, data, error}] = useLazyQuery<any>(QUERY);

if(loading){
   console.log('loading...');
}

if(data){
   console.log(data);
}

if(error){
   // Retry for 3 times with a specific interval and then if after 3 times logging the error
}

问题:

如上面的代码片段所述,我想以特定的时间间隔重试运行查询 3 次,然后如果错误再次发生第 4 次,则记录错误消息。

我已经查看了有关 refetch 的 apollo 客户端文档,但找不到方法。
由于我是阿波罗的新手并做出反应,如果您能分享任何真正的想法,我将不胜感激。

0 个答案:

没有答案