'GitHub Actions GraphQL get ID of repository package url

Is it possible to get the ID of the repository package URL with GitHubs GraphQL api?

I have a repository in an organisation with an npm package and the URL of this package looks like this: https://github.com/ORG/repo-name/packages/321798/versions

I can get the ID 321798 with GitHubs REST api:

curl \
  -H "Authorization: token ${GITHUB_TOKEN}" \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/orgs/ORG/packages/npm/PACKAGE_NAME

With GraphQL I have this query. But this ID is not the same as from the REST api call:

query {
  organization(login: "ORG") {
    packages(packageType: NPM, names: ["PACKAGE_NAME"], first: 1) {
      nodes {
        latestVersion {
          id
        }
      }
    }
  }
}

REST api response is: "id": 321798 GraphQL api response is: "id":"P_kwAO7IP0aM4ADdYa"

Is it possible to get the same short numeric ID with GraphQL in GitHub Actions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source