【发布时间】:2021-01-24 15:58:23
【问题描述】:
我跑到一个兔子洞里,所以我在这里问我的问题。
我有一个 useMutation 突变,可将多达 10MB 的 JSON 数据上传到我的数据库。这显然需要很长时间,并且我收到了 timeout 错误,我认为该错误导致查询运行两次,然后将一些数据上传了两次。
如何声明一个突变有更长的超时时间?我在哪里指定超时?我可以指定它不重试吗?
我目前正在使用几个链接:
import { onError } from '@apollo/client/link/error'
import { RetryLink } from '@apollo/client/link/retry'
import { setContext } from '@apollo/client/link/context'
我相信RetryLink (https://www.apollographql.com/docs/link/links/retry/) 可能会有所帮助。目前我有默认设置:
// default settings
const retryLink = new RetryLink({
delay: {
initial: 300,
max: Infinity,
jitter: true,
},
attempts: {
max: 5,
retryIf: (error, _operation) => !!error,
},
})
【问题讨论】:
标签: apollo react-apollo apollo-link