Enable getting comment url

schema-request

#1

I recently tried migrating one of my apps to use the GraphQL API instead of the v3 API, because it vastly simplifies some things. However, there is one missing feature that requires me to keep the old version for now, and that is that I can’t in any good way (that I’ve found at least) get direct links to comments (on issues). Example URL I’m looking for: https://github.com/Alxandr/alxandr.me/issues/37#issuecomment-343733331.


#2

Hey @Alxandr,

I concur, this seems worthy of a schema request. The Issue object has a url field:

url (URI!)
The HTTP URL for this issue

But there isn’t one in the IssueComment object yet.

However, if you’re willing to use a temporary workaround, it should be possible to achieve this with just V4 API. You could fetch the IssueComment.databaseId field and use it to manually construct the url for the issue comment, since it’s predictable:

{{Issue.url}}#issuecomment-{{IssueComment.databaseId}}

Of course, this is not very robust and might break if GitHub changes their url format. But hopefully a proper url field is added to IssueComment soon, making the temporary workaround no longer needed.


#3

This is a great suggestion, @Alxandr & @shurcooL.

I’ve added this to our internal issue tracker to prioritize and add to the schema. We’ll update you here when we have any updates to share.

Thank you,
Brooks


#4

Yeah. I was thinking of doing that, but the databaseId field is deprecated. So I just kept the old HTTP api call for that particular need and migrated the rest. I figured I wasn’t the only one who might need this, so it would probably be added eventually, and then I can migrate the rest.


#5

Hi @Alxandr and @shurcooL, just wanted to let you know that we’ve added the url field to IssueComment. Here’s an example query:

{
  repository(name: "graphql-client", owner: "github") {
    issue(number: 131) {
      title
      url
    }
  }
}

and the result

{
  "data": {
    "repository": {
      "issue": {
        "title": "Expose HTTP Status to Response Object",
        "url": "https://github.com/github/graphql-client/issues/131"
      }
    }
  }
}

#6

@rlinehan, I’m confused about your comment. You said:

Yet in your example query, you fetch an Issue object, not IssueComment.

Issue has had url field since a long time ago, I even mentioned it in my earlier reply. This schema-request is about IssueComment not having one (it’s still not there, as far as I can see).


#7

Hey @shurcooL sorry for the extremely belated reply, and sorry for the incorrect example!

Here’s another example showing this field (correctly this time!)

{
  repository(name: "graphql-client", owner: "github") {
    issue(number: 130) {
      title
      comments(last: 10) {
        nodes {
          url
        }
      }
    }
  }
}

and the result

{
  "data": {
    "repository": {
      "issue": {
        "title": "missing keyword: schema (ArgumentError)",
        "comments": {
          "nodes": [
            {
              "url": "https://github.com/github/graphql-client/issues/130#issuecomment-351094771"
            },
            {
              "url": "https://github.com/github/graphql-client/issues/130#issuecomment-360929880"
            }
          ]
        }
      }
    }
  }
}

For some reason, the docs you linked to at https://developer.github.com/v4/reference/object/issuecomment/ don’t show the addition of this field, but https://developer.github.com/v4/object/issuecomment/ does include this field. I’m not quite sure what is going on with the discrepancy there, but I’ll look into it.


#8

@rlinehan Thank you for following up. That makes sense now, and I’m glad this schema request is resolved.

About the https://developer.github.com/v4/reference/object/issuecomment/ vs https://developer.github.com/v4/object/issuecomment/ discrepancy, that is indeed very strange and confusing. It seems the entire https://developer.github.com/v4/reference/object/ page is an old copy of the v4 docs and should probably be deleted. The latest version is available at https://developer.github.com/v4/object/.

Edit: It looks like there are many, many links like https://developer.github.com/v4/reference/query/, https://developer.github.com/v4/reference/mutation/, https://developer.github.com/v4/reference/scalar/, etc. that are all old copies of the v4 docs. The https://developer.github.com/v4/reference/ page redirects to https://developer.github.com/v4/, but not the “sub-pages”.