【问题标题】:Working With Rate Limits on GitHub's GraphQL API在 GitHub 的 GraphQL API 上使用速率限制
【发布时间】:2018-06-10 06:59:05
【问题描述】:

我了解 GitHub 的 GraphQL API has a rate limit,它要求您使用切片与 firstlastbeforeafter 等。但是,如果我只想要一个特定的计数怎么办场地?例如,我不想获取用户的所有关注者,我只想获取关注者数量。这是查询:

query {
    user(login: "parkerziegler") {
      login,
      name,
      avatarUrl(size: 200)
      bio,
      company,
      location,
      createdAt,
      followers {
        // what can I do here to get the count rather than info on followers?
      }
    }
}

总的来说,我对如何在 GraphQL 中处理这些类型的计算感兴趣,即 SUM 或 ORDER BY。我猜这些需要在服务器上实现,但只是好奇是否有人有任何见解。我一直在阅读一些关于 pagination 的信息,但不知道它是否能解决我的问题。

【问题讨论】:

    标签: github graphql github-api github-graphql


    【解决方案1】:

    您可以在followers 下使用totalCount 获取关注者数量:

    {
      user(login: "parkerziegler") {
        login
        name
        avatarUrl(size: 200)
        bio
        company
        location
        createdAt
        followers {
          totalCount
        }
      }
    }
    

    Try it in the explorer

    你可以查看FollowerConnection对象

    【讨论】:

      猜你喜欢
      • 2021-05-15
      • 2018-09-23
      • 2015-12-17
      • 1970-01-01
      • 2019-04-30
      • 1970-01-01
      • 2021-11-28
      • 2016-04-29
      • 2020-09-02
      相关资源
      最近更新 更多