IssueId & Comment Id between v3 and graphQL

community-help

#1

I have a mixed implementation of GraphQL and v3 since some of the features are yet to be released.

Is there a way to co-relate the id returned by GraphQL to v3?

In case of Issues, the number field returned by GraphQL(to get issues) can be used as IssueId for v3 update/delete.

However, in case of comments, there is no number field, which leaves me with no way to update/delete comment using v3 for the comments created by GraphQL.

Off course, I can go back to doing create comments with v3 but trying to figure out if there was a way.


#2

Hi @bsreera! Many of the objects have databaseId fields which return the v3 ID. For example, this query:

{
  repository(owner:"rmosolgo", name:"graphql-ruby") {
    issues(first: 1) {
      nodes {
        comments(first:1) {
          nodes {
            databaseId
          }
        }
      }
    }
  }
}

returns:

{
  "data": {
    "repository": {
      "issues": {
        "nodes": [
          {
            "comments": {
              "nodes": [
                {
                  "databaseId": 73768229
                }
              ]
            }
          }
        ]
      }
    }
  }
}

the same comment may be found with:

https://api.github.com/repos/rmosolgo/graphql-ruby/issues/comments/73768229

Does that sound like it would work for you?


#3

@rmosolgo Thanks. This does work. This helps me get the v3 Id from graphQL.

Is there a way to get the other way around too?


#4

@rmosolgo @bsreera first of all thanks a lot for the information provided in this thread, it is really valuable for my needs.

@rmosolgo I would really appreciate case you can give me some feedback on some specific questions:

  • Regardless the deprecation messages on GraphQL API V4 related to databaseId. See:

    Deprecation notice
    Exposed database IDs will eventually be removed in favor of global Relay IDs.

    Can we expect to access that field on node Comment until the mutation UpdateComment is implemented under the new GraphQL API V4?

  • From the previous question, an keeping in mind all databaseId deprecations. Should we expect they will be there until GraphQL provides all features given by current REST API? Should we expect a kind of release note or message to be prepared for the end of life of deprecation fields?

Thank you very much in advance!


#5

Hi @dsaenztagarro,

Should we expect they will be there until GraphQL provides all features given by current REST API?

Despite the databaseId field being deprecated from its inception, this isn’t a field that we intend to remove from the GraphQL schema until the complete deprecation of the REST API. We understand that the GraphQL API doesn’t have full parity with the REST API, so we keep the databaseId around to make the transition easier but eventually we’d like to use globally unique id fields as the source of truth in referencing an object in the API.

Should we expect a kind of release note or message to be prepared for the end of life of deprecation fields?

Yes, sit tight! We’re working on a better way to communicate deprecated pieces of schema, and when / if they will be removed from the schema - but rest assured, databaseId isn’t going away any time soon.

As an aside, when building tools and integrations that use either GitHub’s REST API or GraphQL API, we advise you to persist both the databaseId and id so that you can easily reference those objects from either the REST API or GraphQL API.

We also hope to add a way to see the global (GraphQL) ID from any REST resource, but this functionality does not yet exist.


#6

Hey @dsaenztagarro ! We’ve just posted an announcement about these fields, let me know if you still have any questions or concerns :slight_smile:


#7

@d12 thank you very much for taking care of informing me!. It is really appreciated.

I :heart: the fact the the announcement explains the reasons that motivated the changes and why finally has been reverted that decision.

@bswinnerton @d12 very good job with the communication and solving doubts. It makes me feel really confident using both REST / GraphQL APIs. Thanks!