2

是否可以像使用REST API v3一样使用GitHub GraphQL API v4列出所有 github 的组织?

遵循有限的示例电话:

$ curl https://api.github.com/organizations?since=32358551
[
  {
    "login": "NxtReader",
    "id": 32358576,
    "url": "https://api.github.com/orgs/NxtReader",
    "repos_url": "https://api.github.com/orgs/NxtReader/repos",
    "events_url": "https://api.github.com/orgs/NxtReader/events",
    "hooks_url": "https://api.github.com/orgs/NxtReader/hooks",
    "issues_url": "https://api.github.com/orgs/NxtReader/issues",
    "members_url": "https://api.github.com/orgs/NxtReader/members{/member}",
    "public_members_url": "https://api.github.com/orgs/NxtReader/public_members{/member}",
    "avatar_url": "https://avatars3.githubusercontent.com/u/32358576?v=4",
    "description": null
  },
  {
    "login": "fokkmandag",
    "id": 32358602,
    "url": "https://api.github.com/orgs/fokkmandag",
    "repos_url": "https://api.github.com/orgs/fokkmandag/repos",
    "events_url": "https://api.github.com/orgs/fokkmandag/events",
    "hooks_url": "https://api.github.com/orgs/fokkmandag/hooks",
    "issues_url": "https://api.github.com/orgs/fokkmandag/issues",
    "members_url": "https://api.github.com/orgs/fokkmandag/members{/member}",
    "public_members_url": "https://api.github.com/orgs/fokkmandag/public_members{/member}",
    "avatar_url": "https://avatars2.githubusercontent.com/u/32358602?v=4",
    "description": null
  }
]
4

1 回答 1

2

您可以使用带有type:orgas SearchResultItem可以容纳Organization对象的搜索查询:

{
  search(first: 100, type: USER, query: "type:org") {
    userCount
    pageInfo {
      hasNextPage
      endCursor
    }
    edges {
      node {
        ... on Organization {
          login
          name
          description
        }
      }
    }
  }
}

对于分页,如果is ,您可以获取以afterparam 作为最后一个endCursor值的下一个请求,例如:hasNextPagetrue

search(after: "Y3Vyc29yOjEwMA==", first: 100, type: USER, query: "type:org")
于 2017-09-30T02:11:29.207 回答