0

这是一个相当奇怪的问题。

我有一个相当简单的查询,无论我触发多少次,它都在 Graphiql 中运行得非常好

但是在浏览器中,当我调用data.refetch(). 最奇怪的是,在 Chromium 中 Network error: Converting circular structure to JSON ,如果 FF 错误是 Network error: cyclic object value

在我没有安装 redux-dev-tools 的 Chrome 中,错误与 Chromium 中的相同

其他查询很好地重新获取,但是这个被卡住了!当然,我已经多次重新启动服务器,清除缓存等。

我正在使用 apollo v2,查询没什么特别的:

query ProductsListQuery($offset: Int!, $limit: Int!) {
  products(offset: $offset, limit: $limit) {
    items {
      id
      title
      shortDescription
      tags
      imagesIds
      __typename
    }
    total
    __typename
  }
}

结果:

{
  "data": {
    "products": {
      "items": [
        {
          "id": "5a39b5469066625581a326c4",
          "title": "Test1",
          "shortDescription": "",
          "tags": [],
          "imagesIds": {
            "main": null
          },
          "__typename": "Product"
        },
        {
          "id": "5a39b55b9066625581a3270b",
          "title": "Test2",
          "shortDescription": "",
          "tags": [],
          "imagesIds": {
            "main": null
          },
          "__typename": "Product"
        }
      ],
      "total": 2,
      "__typename": "ProductsPaginated"
    }
  }
}
4

1 回答 1

4

感谢@Daniel Rearden,我研究了重新获取是如何触发的,发现这不起作用,原因我无法解释:

<Button onClick={data.refetch} />

但这有效

<Button onClick={() => data.refetch() />

于 2017-12-21T13:39:52.597 回答