【问题标题】:extend apollo mutation timeout延长阿波罗突变超时
【发布时间】: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


    【解决方案1】:

    500 级错误是服务器端问题。在这种情况下,您的服务器是指示存在超时的服务器,因此客户端无需执行任何操作。您必须检查您的服务器配置并最终解决。

    【讨论】:

      猜你喜欢
      • 2019-04-02
      • 2017-03-23
      • 2019-02-20
      • 2019-04-16
      • 2017-09-04
      • 2019-02-08
      • 1970-01-01
      • 2019-12-06
      • 2018-12-19
      相关资源
      最近更新 更多