{"id":20874660,"url":"https://github.com/neomutt/test-graphql","last_synced_at":"2026-04-26T16:32:23.608Z","repository":{"id":72106994,"uuid":"450809962","full_name":"neomutt/test-graphql","owner":"neomutt","description":"Sample scripts for GitHub's GraphQL","archived":false,"fork":false,"pushed_at":"2023-10-08T00:24:41.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-03T15:43:57.181Z","etag":null,"topics":["graphql","scripts"],"latest_commit_sha":null,"homepage":"https://docs.github.com/en/graphql/overview/explorer","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neomutt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-22T12:23:30.000Z","updated_at":"2023-02-27T23:05:41.000Z","dependencies_parsed_at":"2024-11-18T09:30:49.058Z","dependency_job_id":null,"html_url":"https://github.com/neomutt/test-graphql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/neomutt/test-graphql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neomutt%2Ftest-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neomutt%2Ftest-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neomutt%2Ftest-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neomutt%2Ftest-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neomutt","download_url":"https://codeload.github.com/neomutt/test-graphql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neomutt%2Ftest-graphql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32305035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","scripts"],"created_at":"2024-11-18T06:35:35.260Z","updated_at":"2026-04-26T16:32:23.594Z","avatar_url":"https://github.com/neomutt.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL Sample Scripts\n\nGitHub provides a REST API for its services so that users can automate tasks.\nThis has now been superceded by a GraphQL API which is even more powerful.\n\n- **REST**: https://en.wikipedia.org/wiki/Representational_state_transfer\n- **GraphQL**: https://en.wikipedia.org/wiki/GraphQL\n\nThis repo contains some simple scripts to perform complex queries in a single call.\n\n## Explorer\n\nGitHub provides an Explorer service.  Once logged in, you can run queries\nagainst real data.  GraphQL is fully introspective and the Explorer is very well\ndocumented.  (Hover over object to learn what they are, click for full docs)\n\n- **Explorer**: https://docs.github.com/en/graphql/overview/explorer\n\nThe `.ql` scripts can be cut'n'pasted into the Explorer.\n\n## Pre-requisites\n\nTo run the script, you'll need to install Python package: \"requests\".\nYou'll also need a \"Personal Access Token\" from GitHub.\n\n- Go to: https://github.com/settings/tokens\n- \"Create new token\"\n- Save the token string\n\nIn your shell, create an environment variable, e.g.\n\n- `export GITHUB_TOKEN=\"ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"`\n\n## Running\n\nNow you can run the script.\nIt takes a number as an argument.\nThe number should be an Issue, Pull Request or Discussion number.\n\nHere are some working examples:\n\n```sh\n# Pull Request\n./graphql.py 3199\n\n# Issue\n./graphql.py 3200\n\n# Discussion\n./graphql.py 3203\n```\n\n## Scripts\n\nThese GraphQL scripts can be executed using the GitHub `gh` tool.\nMost of them take named parameters.\nThose marked with `!` are required -- they don't have default values.\n\n| GraphQL                                      | Parameters (Required!)    | Description                                                    |\n| :------------------------------------------- | :------------------------ | :------------------------------------------------------------- |\n| [commit.ql](commit.ql)                       | org, repo, commit!        | Show the details of a commit                                   |\n| [discussion.ql](discussion.ql)               | org, repo, number!        | Show the comments and reactions of a discussion                |\n| [issue.ql](issue.ql)                         | org, repo, number!        | Overview of an Issue                                           |\n| [multi.ql](multi.ql)                         | org, repo, number!        | Get an Issue/Pull Request/Discussion, without knowing the type |\n| [org-repos.ql](org-repos.ql)                 | org, count                | List the first `$count` repos on `$org`                        |\n| [pr.ql](pr.ql)                               | org, repo, number!        | Overview of a Pull Request                                     |\n| [pr-checks.ql](pr-checks.ql)                 | org, repo, number!        | Show the checks run on a PR                                    |\n| [pr-commits.ql](pr-commits.ql)               | org, repo, number!        | Show the commits and merge commit of a Pull Request            |\n| [pr-paged.ql](pr-paged.ql)                   | org, repo, cursor         | Paged list of merged Pull Requests                             |\n| [rate-limit.ql](rate-limit.ql)               |                           | Check how many queries have been used / are left               |\n| [search-discussion.ql](search-discussion.ql) |                           | Search a NeoMutt discussion                                    |\n\n```sh\ngh api graphql -f query=\"$(cat rate-limit.ql)\"\n```\n\nmight return:\n\n```json\n{\n  \"data\": {\n    \"rateLimit\": {\n      \"cost\": 1,\n      \"limit\": 5000,\n      \"remaining\": 4985,\n      \"used\": 15,\n      \"resetAt\": \"2023-10-08T00:31:18Z\",\n      \"nodeCount\": 0\n    }\n  }\n}\n```\n\nTo specify parameters, use the `-F key=value` option:\n\n```sh\ngh api graphql -F org=neomutt -F repo=neomutt -F number=4037 -f query=\"$(cat pr-commits.ql)\"\n```\n\nSample output:\n\n```json\n{\n  \"data\": {\n    \"organization\": {\n      \"repository\": {\n        \"pullRequest\": {\n          \"number\": 4037,\n          \"title\": \"Refactor the Message Window Usage\",\n          \"merged\": true,\n          \"commits\": {\n            \"nodes\": [\n              {\n                \"commit\": {\n                  \"messageHeadline\": \"force initial window size\",\n                  \"oid\": \"f3c4aa207ae2c5e2a0f344d837121ab96e5525ef\"\n                }\n              },\n              {\n                \"commit\": {\n                  \"messageHeadline\": \"msgwin: indefinite article\",\n                  \"oid\": \"e4f3b9380d33e2b27c5542faecf89fc91442ce59\"\n                }\n              },\n              {\n                \"commit\": {\n                  \"messageHeadline\": \"msgwin: add new features\",\n                  \"oid\": \"2a9b54b1818ee200fa8cfef00b6abf7a65d14ec3\"\n                }\n              },\n              {\n                \"commit\": {\n                  \"messageHeadline\": \"msgcont: fix redraw\",\n                  \"oid\": \"41c015df55fe876e63f44dee172fa575880ef5df\"\n                }\n              }\n            ]\n          },\n          \"mergeCommit\": {\n            \"messageHeadline\": \"merge: refactor the MessageWindow\",\n            \"oid\": \"5a855fd927edab3843d745d1cf754116479ab275\"\n          }\n        }\n      }\n    }\n  }\n}\n```\n\nTo get multiple pages of data, you can use the `endCursor` field and the `after` parameter:\n\n```sh\n# First run (no parameters)\ngh api graphql -f query=\"$(cat pr-paged.ql)\"\n```\n\nOutput contains something like:\n\n```\n\"pageInfo\": {\n  \"hasNextPage\": true,\n  \"endCursor\": \"Y3Vyc29yOnYyOpHOBjMBXA==\"\n}\n```\n\nTo get the next page, run:\n\n```\ngh api graphql -F cursor=\"Y3Vyc29yOnYyOpHOBjMBXA==\" -f query=\"$(cat pr-paged.ql)\"\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneomutt%2Ftest-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneomutt%2Ftest-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneomutt%2Ftest-graphql/lists"}