You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何在GitHub GraphQL API中重复调用字段可绕过分页限制?

Why doesn't my second GitHub GraphQL query require pagination?

Great catch! This is a specific behavior of the GitHub GraphQL API's pagination rules, and it makes sense once you break down what's happening in each query:

Let's unpack the two queries

  1. First query (throws pagination error)
    Your first query only asks for the nodes list from the repositories connection, with no other metadata about that connection:

    query { 
      user(login:"armsp"){ 
        repositories{ 
          nodes{ name issues(states: OPEN){ totalCount } } 
        } 
      } 
    }
    

    GitHub's API enforces strict pagination here because you're only requesting list data — it wants you to explicitly set first or last to limit how many results you fetch, which prevents accidental large requests that could overload their servers.

  2. Second query (works without explicit pagination)
    In your second query, you're making two separate calls to the repositories connection under the same user:

    query { 
      user(login:"armsp"){ 
        repositories{ totalCount } 
        repositories{ nodes{ name issues(states: OPEN){ totalCount } } } 
      } 
    }
    

    When you include a request for totalCount (a single value, not a list) alongside your nodes request, the API relaxes its strict pagination check for the nodes list. Instead of throwing an error, it automatically returns up to 100 results (GitHub's default limit for connection fields when you don't specify first/last).

A critical clarification: You're not getting "all" results

If armsp has more than 100 repositories, your second query will only return the first 100. The API still limits the result set — it just doesn't force you to explicitly define that limit in this scenario. To fetch every repository, you'd still need to implement proper pagination using first/last paired with after/before cursors.

Test this yourself to confirm

  • If you remove the repositories{ totalCount } line from your second query, it will immediately throw the same MISSING_PAGINATION_BOUNDARIES error as your first query.
  • If you run the second query for a user with over 100 repositories, you'll see the nodes array cuts off at 100 entries.

内容的提问来源于stack exchange,提问作者jar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:09:56