Skip to content

GraphQL getting filename,file content and commit date #24419

Discussion options

You must be logged in to vote

Hey @anvinraj!

I believe the GraphQL API can do some of you’re looking for by using a feature called aliasing, which allows you to give connections a unique name, and execute multiple of the same connections in a single query. Take your example run against one of my Repositories:

query {
  repository(owner: "nickvanw", name: "ircx") {
    commit: object(expression: "49cff0c1f801176c4cdf774252a5803f25cdb815") {
      ... on Commit {
        oid
      }
    }
content:object(expression: "master:README.md") {
  ... on Blob {
    text
  }
}

filename: object(expression: "master:example/") {
  ... on Tree {
    entries {
      name
    }
  }
}

}
}

This returns all three of them, in one query:

{…

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants