Github GraphQL存储库查询,使用两个对象

时间:2018-03-30 19:54:49

标签: graphql github-graphql

查询Github GraphQL时如何使用多个对象?

如果第二个对象被取消注释,以下内容将会中断:

query {
  repository(owner:"rails", name:"rails") {
    object(expression:"master") {
      ... on Commit {
        history {
          totalCount
        }
      }
    }
    # object(expression: "master:README.md") {... on Blob {byteSize}}
  }
}

如何让它运作? THX

1 个答案:

答案 0 :(得分:2)

使用别名

query {
  repository(owner:"rails", name:"rails") {
    object(expression:"master") {
      ... on Commit {
        history {
          totalCount
        }
      }
    },
    second_object: object(expression: "master:README.md") {... on Blob {byteSize}}
  }
}