2

If I use github v3 api to access the directory contents of a public repository using the following query:

curl https://api.github.com/repos/w3c/webappsec/contents/

what is the equivalent in graphql?

I can get for example the description of the repository by sending the following to: https://api.github.com/graphql

query TestQuery{
    repository(owner:"w3c" name:"webappsec"){
      description
    }
  }

But how can I get the contents of a repository's directory?

Marinos An
  • 9,481
  • 6
  • 63
  • 96

1 Answers1

1

You can use object(expression: "branch_name:") and list the tree entries:

{
  repository(owner: "w3c", name: "webappsec") {
    object(expression: "master:") {
      ... on Tree {
        entries {
          name
          type
          mode
        }
      }
    }
  }
}

Try it in the explorer

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159