| Apr | MAY | Jun |
| 30 | ||
| 2017 | 2018 | 2019 |
COLLECTED BY
Collection: Live Web Proxy Crawls
node_id. In GraphQL, it's an idfield on the node interface. For a refresher on what "node" means in GraphQL, see "Introduction to GraphQL."
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.
curl -i -u username:token https://api.github.com/user
you'll get a response that includes the node_id of the authenticated user:
Status: 200 OK
{
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false,
"name": "monalisa octocat",
"company": "GitHub",
"blog": "https://github.com/blog",
"location": "San Francisco",
"email": "octocat@github.com",
"hireable": false,
"bio": "There once was...",
"public_repos": 2,
"public_gists": 1,
"followers": 20,
"following": 0,
"created_at": "2008-01-14T04:33:35Z",
"updated_at": "2008-01-14T04:33:35Z",
"total_private_repos": 100,
"owned_private_repos": 100,
"private_gists": 81,
"disk_usage": 10000,
"collaborators": 8,
"two_factor_authentication": true,
"plan": {
"name": "Medium",
"space": 400,
"private_repos": 20,
"collaborators": 0
},
"node_id": "MDQ6VXNlcjU4MzIzMQ=="
}
node_id value is MDQ6VXNlcjU4MzIzMQ==. You can use this value to query the same object in GraphQL.
You'll need to know the object's type first, though. You can check the type with a simple GraphQL query:
Run in Explorer
query {
node(id:"MDQ6VXNlcjU4MzIzMQ==") {
__typename
}
}
This type of query—that is, finding the node by ID—is known as a "direct node lookup."
When you run this query, you'll see that the __typenameisUser.
User that we'd like to query:
Run in Explorer
query {
node(id:"MDQ6VXNlcjU4MzIzMQ==") {
... on User {
name
login
}
}
}
This type of query is the standard approach for looking up an object by its global node ID.