首页 > 解决方案 > 从 GitHub GraphQL 获取 repositoryOwner 数组

问题描述

我有这个查询:

query { 
  repositoryOwner(login: "jcubic") {
    repositories(first: 20, orderBy: {field: STARGAZERS, direction: DESC}, privacy: PUBLIC) {
      edges {
        repository:node {
          name
          stargazers {
            totalCount
          }
        }
      }
    }
  }
}

是否可以让多个用户而不是单个用户?

标签: graphqlgithub-api

解决方案


在帮助下,我能够使用 ID 创建查询(它们来自我和 linus torvalds):

{
  nodes(ids: ["MDQ6VXNlcjI4MDI0MQ==", "MDQ6VXNlcjEwMjQwMjU="]) {
    ... on User {
      name
      login
    }
    ... on RepositoryOwner {
      repositories(first: 20, orderBy: {field: STARGAZERS, direction: DESC}, privacy: PUBLIC) {
        edges {
          repository: node {
            name
            stargazers {
              totalCount
            }
          }
        }
      }
    }
  }
}

推荐阅读