REST API interop - mismatched IDs


#1

I’m working with the GraphQL API to get the CommitComments of a pull request, and delete ones by a specific user.

The problem I am running into is there’s seemingly no way to delete comments currently implemented by the GraphQL API… I figure “no problem, I’ll delete them with the REST API” but there is a problem…

The IDs the GraphQL API provide look like MDEzOkNvbW1pdENvbW1lbnQyMzQyODQzMg== which are not accepted by the REST API. Base64 decoding that I receive 013:CommitComment23428432 which I could parse the id I need 23428432 out of… but having to do string manipulation on IDs seems very dangerous to me…

I’d like to see the addition of a “restID” or some such for interop with the existing REST api…


#2

:wave: @donatj,

We have the databaseId field to map back to the raw “database” values that we use in the REST API. A query like this should get the information you’re looking for:

query {
  repository(owner:$owner, name:$name) {
    commitComments(last:100) {
      edges {
        node {
          id
          databaseId
          author {
            login
          }
        }
      }
    }
  }
}

You’ll notice that the databaseId field is deprecated, that’s just because one day we’ll want to address everything by a global id and not the underlying databaseId. Until that day comes, it may be a good idea to persist both ids in your application so that you can access them via the REST API or our GraphQL API.

but having to do string manipulation on IDs seems very dangerous to me…

It definitely is :smile:. These IDs are meant to be opaque and the structure could change at any time.

I hope this helps!


#3

Is there any plan to add the new graphql ID to the REST API?

This seems like a maintainable approach over providing access to the old deprecated ID from the new API.


#4

BTW, the docs now say that databaseId is scheduled to be removed altogether from the GraphQL API by 2018-07-01.