分页查询的Apollo客户端缓存值

时间:2019-07-31 05:15:38

标签: javascript caching pagination apollo react-apollo

我已将apollo客户端配置为将InMemoryCache与persistCache一起使用。我有一个分页查询,可以查询多个页面,以便获取第0页,它会触发/api/core/master/cust?_page=0&_limit=5/api/core/master/cust?_page=1&_limit=5来获取第1页。

持久性缓存存储ROOT_QUERY如下所示:

"ROOT_QUERY": {
  "values({\"query\":\"/api/core/master/cust?_page=0&_limit=5\"})": [
    {
      "type": "id",
      "generated": false,
      "id": "Customers:81",
      "typename": "Customers"
    },
    {
      "type": "id",
      "generated": false,
      "id": "Customers:82",
      "typename": "Customers"
    },
    {
      "type": "id",
      "generated": false,
      "id": "Customers:83",
      "typename": "Customers"
    },
    {
      "type": "id",
      "generated": false,
      "id": "Customers:84",
      "typename": "Customers"
    },
    {
      "type": "id",
      "generated": false,
      "id": "Customers:85",
      "typename": "Customers"
    }
  ],
  "pagination": {
    "type": "json",
    "json": {
      "pageNumber": 0,
      "pageSize": 5,
      "totalRecordCount": 15
    }
  }
},

问题在于,values.query总是被最后一个请求覆盖。显然我做的不对。有想法吗?

让我知道是否需要更多信息。

谢谢

0 个答案:

没有答案