首页 > 解决方案 > GitHub GraphQL api 说还有另一个页面,但是使用游标时找不到结果

问题描述

我有一个基本查询来获取有关某些问题的信息。

query getIssues($owner: String!, $repo: String!, $milestoneId: Int!, $cursor:String) {
  repository(owner: $owner, name: $repo) {
    milestone(number: $milestoneId) {
      title
      issues(first: 100, after:$cursor) {
        totalCount
        edges {
          node {
            title
            state
            createdAt
            closedAt
          }
        }
        pageInfo
        {
          hasNextPage
          endCursor
        }
      }
    }
  }
}

当我使用参数时:

{"owner": "Me", "repo": "MyRepo", "milestoneId": 1, "cursor": null}

我收到有关前 100 个问题的信息。有一个totalCount213,paginationInfo告诉我还有另一页,并给我一个光标转到下一页。

当我执行另一个查询时,将字段$cursor替换为由endCursor. 我收到这个作为答案:

{
  "data": {
    "repository": {
      "milestone": {
        "title": "MilestoneName",
        "issues": {
          "totalCount": 213,
          "edges": [],
          "pageInfo": {
            "hasNextPage": false,
            "endCursor": null
          }
        }
      }
    }
  }
}

是否有额外的步骤来使用光标进行分页工作?

标签: graphqlgithub-api

解决方案


推荐阅读