GitHub GraphQL API v4与REST API v3

时间:2017-09-28 10:19:12

标签: api github graphql github-api github-graphql

是否可以像GitHub GraphQL API v4一样列出所有使用REST API v3的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
  }
]

1 个答案:

答案 0 :(得分:2)

您可以将搜索查询与type:org一起使用,因为SearchResultItem可以容纳Organization个对象:

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

对于分页,如果afterendCursor,您可以使用hasNextPage参数作为最后true值获取下一个请求,例如:

search(after: "Y3Vyc29yOjEwMA==", first: 100, type: USER, query: "type:org")
相关问题