GraphQL API release asset ID was changed #166793
-
Select Topic AreaQuestion BodyPreviously I was storing the release asset ID fetched from the GraphQL API and using it with the REST API to fetch back the asset when I needed it. However now it seems that the Oh and also the documentation still says the Just in case I'm being very silly and I've overlooked something, here is the query I'm using: {
_0: repository(owner: "CaffeineMC", name: "sodium") {
owner {
login
}
name
releases(first: 100) {
nodes {
name
description
isPrerelease
releaseAssets(first: 10) {
nodes {
id # AFAIK this used to give an i32 but now it gives me a string
name
}
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 1 reply
-
|
Change in Previously, the Solution: Extract REST-Compatible Asset ID from GraphQLYou can convert the GraphQL Option 1: Use
|
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
|
You are seeing two different kinds of IDs.
What to do now
{
repository(owner: "CaffeineMC", name: "sodium") {
releases(first: 100) {
nodes {
name
releaseAssets(first: 10) {
nodes {
id # global node ID (string, GraphQL only)
databaseId # integer you can pass to REST
name
downloadUrl
}
}
}
}
}
}Then call REST with
query($nodeId: ID!) {
node(id: $nodeId) {
... on ReleaseAsset {
databaseId
name
}
}
}Why this changed from what you saw before In GraphQL the Practical tips
That should let your existing REST calls keep working without changing how you find assets in GraphQL. |
Beta Was this translation helpful? Give feedback.
-
TL;DR: Replace
|
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
|
Here’s the bottom line first, so you don’t waste more time: ❌ You can no longer rely on GraphQL’s ReleaseAsset.id as the REST asset ID. GitHub silently migrated this field from an integer to a global node ID (opaque base64 string). This means: The GraphQL id is now a Node ID, not a REST resource ID REST API still requires the integer asset ID GitHub has not updated documentation and did not list this as a breaking change, but it is one You cannot convert the GraphQL “node ID” back to the REST integer ID But there is a working solution. ✅ Why this happened GitHub has been progressively migrating parts of the GraphQL schema to use globally unique opaque Node IDs, not numeric primary keys. This is part of their GraphQL v4 “node unification” initiative. Historically: GraphQL id (integer) === REST id (integer) Now: GraphQL id = Base64 Node ID (e.g. "RA_kgDOLLB…") These are different values and not transformable. ❗ So how do you get the REST asset_id now? You must ask GraphQL for the REST ID via the new "databaseId" field. GitHub still exposes the integer “database ID” for backwards compatibility — they just don’t expose it by default in the docs. Try this: { Example output: Use databaseId with the REST API endpoint: GET /repos/{owner}/{repo}/releases/assets/{asset_id} 🧠 Why databaseId is the right field GitHub’s official convention: id → GraphQL global Node ID (string) databaseId → internal numeric primary key (= the one REST uses) This is true for: Issues Releases Pull requests Comments Assets Commits (if applicable) Discussions Labels You are correct: The schema declares id: ID! Historically that was a 32-bit signed integer Now ID! is a string node ID, but docs haven’t updated This was not listed in breaking changes You're not silly — GitHub simply failed to document this migration step. 🟢 TL;DR Solution Use databaseId instead of id. releaseAssets { nodes { databaseId } } That numeric value works with all REST release asset endpoints. |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
|
The solution I've used is storing the GraphQL node ID, and luckily the node ID is also present in the REST API. So I just download all assets and find the one with the matching node ID. It's not ideal but it works and is much cleaner than any other solution I could think of. |
Beta Was this translation helpful? Give feedback.
The solution I've used is storing the GraphQL node ID, and luckily the node ID is also present in the REST API. So I just download all assets and find the one with the matching node ID. It's not ideal but it works and is much cleaner than any other solution I could think of.