4

How to use more than one objects when querying Github GraphQL?

The following will break if the 2nd object is uncommented:

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

How to make it working? Thx

xpt
  • 20,363
  • 37
  • 127
  • 216
  • This Q/A helped me find a [better Github search approach](https://medium.com/@suntong001/query-github-graphql-9a4547d33bad), FYI. – xpt Mar 31 '18 at 20:04

1 Answers1

6

Use alias:

query {
  repository(owner:"rails", name:"rails") {
    object(expression:"master") {
      ... on Commit {
        history {
          totalCount
        }
      }
    },
    second_object: object(expression: "master:README.md") {... on Blob {byteSize}}
  }
}
Ben
  • 5,069
  • 4
  • 18
  • 26