Skip to the content.

GraphQL 参考(github-api-reference)

端点:POST https://api.github.com/graphql;正文 { "query": "...", "variables": {...} }。 认证与 REST 相同(Authorization Bearer);文档:https://docs.github.com/graphql 。

请求结构

{
  "query": "query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { nameWithOwner stargazerCount } }",
  "variables": { "owner": "xinvxueyuan", "name": "github-api-skill" }
}

连接分页

query {
  repository(owner: "xinvxueyuan", name: "github-api-skill") {
    issues(first: 30, orderBy: {field: CREATED_AT, direction: DESC}) {
      totalCount
      pageInfo { hasNextPage endCursor }
      edges { cursor node { number title state } }
    }
  }
}

常用顶层字段

变更(mutation)示例

mutation($id: ID!, $state: IssueState!) {
  updateIssue(input: {id: $id, state: $state}) { issue { number state } }
}

内省 / 判断字段是否最新

限流