How to get html_url property in GraphQL

 I am migrating my application from API v3 to v4, into a request I get the content file, with the filename and html_url with GET /repos/:owner/:repo/contents/:path endpoint but I could not migrate this functionality because I don’t know how to get the html_url my current query is

query ($owner: String! $repositoryName: String!, $folderPath: String!) {
  repository(owner: $owner, name:$repositoryName) {
      object(expression: $folderPath) {
      ... on Tree{
        entries {
          name
        	object {
          ... on Blob {
            text
          }
          }
        }
      }
    }
  }
  rateLimit {
    cost
    limit
    nodeCount
    remaining
  }
}

Hi @aperdomob,

Unfortunately, the GraphQL API’s Tree and Blob object don’t expose an HTML URL currently:

https://developer.github.com/v4/object/tree/

https://developer.github.com/v4/object/blob/

We’ve let the team know you expressed interest in exposing this field for those objects. Moving forward, we recommend using the REST API v3’s Contents API to obtain a file’s html_url value.

Cheers!

1 Like