You can access most objects in GitHub (users, issues, pull requests, etc.) using either the REST API or the GraphQL API. With a recent update, you can find the global node ID of many objects from within the REST API and use these IDs in your GraphQL operations.
Note: In REST, the global node ID field is named node_id. In GraphQL, it's an id field on the node interface. For a refresher on what "node" means in GraphQL, see "Introduction to GraphQL."
Putting global node IDs to use
You can follow three steps to use global node IDs effectively:
- Call a REST endpoint that returns an object's
node_id. - Find the object's type in GraphQL.
- Use the ID and type to do a direct node lookup in GraphQL.
Let's walk through an example.
1. Call a REST endpoint that returns an object's node ID
If you request the authenticated user:
$ curl -i -u username:token http(s)://[hostname]/api/v3/user
you'll get a response that includes the node_id of the authenticated user:
{