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

问题描述 投票:0回答:1

这是一个非常奇怪的问题。

我有一个相当简单的查询,无论我触发多少次,它在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"
    }
  }
}
react-apollo apollostack
1个回答
1
投票

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

<Button onClick={data.refetch} />

但这很有效

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

© www.soinside.com 2019 - 2024. All rights reserved.