网络错误:重新获取时将循环结构转换为 JSON

Dan*_*hko 2 apollostack react-apollo

这是一个很奇怪的问题。

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

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

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

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

我使用的是 apollo v2,查询没有什么特别的:

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

结果:

{
  "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"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

Dan*_*hko 5

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

<Button onClick={data.refetch} />

但这有效

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