Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

github graphql api default branch in repository

I have the following query:

{
  repository(owner: "org", name: "name") {
    name
    object(expression: "master:package.json") {
      ... on Blob {
        text
      }
    }
  }
}

but as you can see I have to hardcode master in the object expression. I'm wondering if there's a way to instead use the default branch in that query. Is that possible without having to do 2 queries (1 to get the default branch, then another to get the file content)?

like image 812
Ben Avatar asked Oct 17 '22 22:10

Ben


1 Answers

There was a related question (with bounty too) on that, detailed in this thread... but it is the syntax you are using:

The argument passed to expression on the object field is actually a git revision expression suitable for git rev-parse, so I guess you can have fun with it to do advanced querying.

So any way to specify a revision should do, including HEAD, which would reference the default remote branch. But not the "current branch" though.

like image 198
VonC Avatar answered Oct 21 '22 09:10

VonC