{"id":13602493,"url":"https://github.com/octokit/graphql-action","last_synced_at":"2025-06-16T20:09:05.844Z","repository":{"id":38175496,"uuid":"213717672","full_name":"octokit/graphql-action","owner":"octokit","description":"A GitHub Action to send queries to GitHub's GraphQL API","archived":false,"fork":false,"pushed_at":"2025-06-02T06:46:37.000Z","size":3991,"stargazers_count":130,"open_issues_count":4,"forks_count":25,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-03T23:06:35.627Z","etag":null,"topics":["graphql","hacktoberfest","octokit-js","tooling"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/github-graphql-api-query","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/octokit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-10-08T18:14:58.000Z","updated_at":"2025-06-02T06:46:41.000Z","dependencies_parsed_at":"2023-10-16T16:58:15.303Z","dependency_job_id":"a4f01103-d70d-4d05-8946-b9d2cb08bded","html_url":"https://github.com/octokit/graphql-action","commit_stats":{"total_commits":379,"total_committers":21,"mean_commits":"18.047619047619047","dds":0.4538258575197889,"last_synced_commit":"75157ed1c5002abd092ef4e7f8cc66e9b966c8ab"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/octokit/graphql-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Fgraphql-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Fgraphql-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Fgraphql-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Fgraphql-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octokit","download_url":"https://codeload.github.com/octokit/graphql-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octokit%2Fgraphql-action/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260230731,"owners_count":22978177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","hacktoberfest","octokit-js","tooling"],"created_at":"2024-08-01T18:01:25.317Z","updated_at":"2025-06-16T20:09:05.800Z","avatar_url":"https://github.com/octokit.png","language":"JavaScript","readme":"# Octokit Request Action\n\n\u003e A GitHub Action to send queries to GitHub's GraphQL API\n\n[![Build Status](https://github.com/octokit/graphql-action/workflows/Test/badge.svg)](https://github.com/octokit/graphql-action/actions)\n\n## Usage\n\nMinimal example\n\n```yml\nname: Log latest release\non:\n  push:\n    branches:\n      - main\n\njobs:\n  logLatestRelease:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: octokit/graphql-action@v2.x\n        id: get_latest_release\n        with:\n          query: |\n            query release($owner:String!,$repo:String!) {\n              repository(owner:$owner,name:$repo) {\n                releases(first:1) {\n                  nodes {\n                    name\n                    createdAt\n                    tagName\n                    description\n                  }\n                }\n              }\n            }\n          owner: ${{ github.event.repository.owner.name }}\n          repo: ${{ github.event.repository.name }}\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n      - run: \"echo 'latest release: ${{ steps.get_latest_release.outputs.data }}'\"\n```\n\nYou can also use the `variables` parameter to pass variables.\n\n```yml\n- uses: octokit/graphql-action@v2.x\n  with:\n    query: |\n      query release($owner:String!,$repo:String!) {\n        repository(owner:$owner,name:$repo) {\n          releases(first:1) {\n            nodes {\n              name\n              createdAt\n              tagName\n              description\n            }\n          }\n        }\n      }\n    variables: |\n      owner: ${{ github.event.repository.owner.name }}\n      repo: ${{ github.event.repository.name }}\n  env:\n    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n```\n\nTo access deep values of `outputs.data`, use [`fromJSON()`](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson).\n\n## Debugging\n\nTo see additional debug logs, create a secret with the name: `ACTIONS_STEP_DEBUG` and value `true`.\n\n## How it works\n\n`octokit/graphql-action` is using [`@octokit/graphql`](https://github.com/octokit/graphql.js/) internally with the addition\nthat requests are automatically authenticated using the `GITHUB_TOKEN` environment variable. It is required to prevent rate limiting, as all anonymous requests from the same origin count against the same low rate.\n\nThe actions sets `data` output to the response data. Note that it is a string, you should use [`fromJSON()`](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) to access any value of the response. The action also sets `headers` (again, to a JSON string) and `status`.\n\n## Preview Media Types\n\nNew features of graphql require the use of an Accept header with a preview media-type.\nThis is supported with a `mediaType` property, e.g.\n\n```yml\nsteps:\n  - uses: octokit/graphql-action@v2.x\n    with:\n      query: |\n        query  pullRequest(\n          $repo:String!\n          $owner:String!) {\n          repository(name:$repo, owner:$owner) { \n            pullRequests(last:1) {\n              nodes {\n                number\n                mergeStateStatus\n              }\n            }\n          }\n        }\n      owner: ${{ github.event.repository.owner.name }}\n      repo: ${{ github.event.repository.name }}\n      mediaType: |\n        previews:\n        - merge-info\n```\n\n## Troubleshooting\n\n### Input variables\n\nIt's important to remark `input variables` are converted to lowercase at runtime. This happens with GitHub Actions by design[^1].\n\n### Example\n\nIn the following example, the variable `itemId` is casted to `itemid` so, when trying to use it in the `query`, the execution will fail because of a missing variable: `itemId`\n\n```graphql\nquery release($itemId: String!) {\n  ...\n\n# Fails with \"Error: Variable $itemId of type String! was provided invalid value\"\nitemId: \"randomId\"\n```\n\nThe recommendation[^1] is to use variables in lowercase to avoid this kind of problems:\n\n```graphql\n# The variable name must be lower-case:\nquery release($itemid: String!) {\n  ...\n\n# Both: in the query and action var declaration:\nitemid: \"randomId\"\n```\n\n[^1]: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctokit%2Fgraphql-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctokit%2Fgraphql-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctokit%2Fgraphql-action/lists"}