{"id":16123750,"url":"https://github.com/austenstone/gh-api-graphql","last_synced_at":"2026-01-21T15:32:59.534Z","repository":{"id":38820364,"uuid":"466244939","full_name":"austenstone/gh-api-graphql","owner":"austenstone","description":"Using the GitHub GraphQL API","archived":false,"fork":false,"pushed_at":"2023-03-07T13:31:05.000Z","size":1318,"stargazers_count":2,"open_issues_count":9,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T17:34:39.547Z","etag":null,"topics":["api","github","graphql"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":false,"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/austenstone.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},"funding":{"github":["austenstone"]}},"created_at":"2022-03-04T19:22:06.000Z","updated_at":"2023-03-05T08:05:07.000Z","dependencies_parsed_at":"2024-10-27T18:15:18.926Z","dependency_job_id":"a353548d-6b51-40e4-b968-3c3b6b7502c1","html_url":"https://github.com/austenstone/gh-api-graphql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/austenstone/gh-api-graphql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fgh-api-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fgh-api-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fgh-api-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fgh-api-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/austenstone","download_url":"https://codeload.github.com/austenstone/gh-api-graphql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austenstone%2Fgh-api-graphql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28635890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T15:01:31.228Z","status":"ssl_error","status_checked_at":"2026-01-21T14:42:58.942Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["api","github","graphql"],"created_at":"2024-10-09T21:18:37.371Z","updated_at":"2026-01-21T15:32:59.510Z","avatar_url":"https://github.com/austenstone.png","language":"TypeScript","funding_links":["https://github.com/sponsors/austenstone"],"categories":[],"sub_categories":[],"readme":"\r\n# GitHub GraphQL API\r\nDemonstraing usage of GitHub GraphQL API.\r\n\r\nYou will need to [create a PAT(Personal Access Token)](https://github.com/settings/tokens/new?scopes=repo) to use most methods.\r\n\r\n## What is GraphQL?\r\nGraphQL is a query language that traverses your data graph to produce a query result tree.\r\n\r\nSee [GraphQL Basics - Build an app with the SpaceX API](https://youtu.be/7wzR4Ig5pTI)\u003cbr\u003e\r\n\u003ca href=\"https://youtu.be/7wzR4Ig5pTI\"\u003e\r\n  \u003cimg src=\"https://img.youtube.com/vi/7wzR4Ig5pTI/maxresdefault.jpg\" width=\"300px\"\u003e\r\n\u003c/a\u003e\r\n\r\nRead [Introduction to GraphQL](https://docs.github.com/en/graphql/guides/introduction-to-graphql).\r\n\r\n## What is the GitHub GraphQL API?\r\nTo create integrations, retrieve data, and automate your workflows, use the [GitHub GraphQL API](https://docs.github.com/en/graphql).\u003cbr\u003eThe GitHub GraphQL API offers more precise and flexible queries than the GitHub REST API.\r\n\r\n### Endpoint\r\n\r\nThere is only one endpoint for the GitHub GraphQL API.\r\n```\r\nhttps://api.github.com/graphql\r\n```\r\nAll requests to this endpoint must contain an authorization header.\r\n```\r\nAuthorization: Bearer ghp_PAT_HERE\r\n```\r\n\r\n# GitHub API Clients\r\nBelow are of the clients that can be used to interact with the GitHub GraphQL API.\r\n\r\nThe list is broken up into the following categories:\r\n- [GUI](#gui)\r\n- [Terminal](#terminal)\r\n- [JavaScript](#javascript)\r\n\r\nThis list is not exhaustive. You can find clients for any language at [graphql.org](https://graphql.org/code/).\r\n\r\nFor sample queries see [GitHub GraphQL Query Samples](https://github.com/github/platform-samples/tree/master/graphql).\r\n\r\nYou must provide a special `Accept` header to utilize upcoming features and changes. See [Schema previews](https://docs.github.com/en/graphql/overview/schema-previews).\r\n\r\n## GUI\r\n\r\n### Explorer GraphiQL\r\nUse the [GraphiQL Explorer](https://docs.github.com/en/graphql/overview/explorer) built into GitHub's documentation or use the official [Online GraphiQL](https://graphiql-online.com/). Be patient with the explorer, it can take a little bit to load the schema.\u003cbr\u003e\r\nRead more on [Using the Explorer](https://docs.github.com/en/graphql/guides/using-the-explorer).\r\n\r\n\u003ca href=\"https://docs.github.com/en/graphql/overview/explorer\"\u003e\r\n  \u003cimg width=\"400px\" src=\"https://user-images.githubusercontent.com/22425467/156842494-b6410489-46ed-403f-9097-2d8b2b354d3c.png\"\u003e\r\n\u003c/a\u003e\r\n\r\n### Insomnia\r\n[Insomnia](https://insomnia.rest/) is an all purpose API Client and has a great GraphQL interface.\r\n\r\n\u003ca href=\"https://insomnia.rest/\"\u003e\r\n  \u003cimg width=\"400px\" src=\"https://user-images.githubusercontent.com/22425467/157262174-63278a74-a9ea-45d1-800b-0da8210b4fb3.png\"\u003e\r\n\u003c/a\u003e\r\n\r\n### Postman\r\n[Postman](https://www.postman.com/) is an incredibly popular all purpose API Client with GraphQL support.\r\n\r\n\u003ca href=\"https://www.postman.com/\"\u003e\r\n  \u003cimg width=\"400px\" src=\"https://user-images.githubusercontent.com/22425467/157262835-5e81f5b9-1ec4-4b40-842c-433ccd5445d8.png\"\u003e\r\n\u003c/a\u003e\r\n\r\n\r\n### GraphQL Playground\r\n[graphql-playground](https://github.com/graphql/graphql-playground) was [deprecated](https://graphql.org/blog/2020-04-03-web-based-graphql-ides-for-the-win/) in favor of web-based IDEs like GraphiQL. Still a great tool.\r\n\r\n\u003ca href=\"https://github.com/graphql/graphql-playground\"\u003e\r\n  \u003cimg width=\"400px\" src=\"https://user-images.githubusercontent.com/22425467/157260489-bae642ce-2b4d-4c5c-946b-a1efde501124.png\"\u003e\r\n\u003c/a\u003e\r\n\r\n## Terminal\r\n\r\n### GitHub CLI\r\nSee [github.com/cli/cli](https://github.com/cli/cli#github-cli) and [cli.github.com/manual](https://cli.github.com/manual/gh_api#examples).\r\n```bash\r\ngh api graphql -f query='query {\r\n  viewer {\r\n    login\r\n  }\r\n}'\r\n```\r\n\r\n### Curl\r\nYou know curl.\r\n```bash\r\ncurl -H \"Authorization: bearer ${GITHUB_TOKEN}\" -X POST -d \" \\\r\n { \\\r\n   \\\"query\\\": \\\"query { viewer { login }}\\\" \\\r\n } \\\r\n\" https://api.github.com/graphql\r\n```\r\n## Javascript\r\n\r\n### Octokit Graphql.js\r\nSee [github.com/octokit/graphql.js](https://github.com/octokit/graphql.js/#graphqljs).\r\n```js\r\nimport { Octokit } from \"octokit\";\r\n\r\nconst octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });\r\n\r\nconst result = await octokit.graphql(`query { \r\n    viewer { \r\n      login\r\n    }\r\n}`)\r\nconsole.log(result)\r\n```\r\n#### Bonus Actions Usage\r\nYou can use [github-script](https://github.com/actions/github-script#run-custom-graphql-queries) to easily implement octokit in your Actions workflows.\r\n```yaml\r\njobs:\r\n  viewer_login:\r\n    runs-on: ubuntu-latest\r\n    steps:\r\n      - uses: actions/github-script@v6\r\n        with:\r\n          script: |\r\n            const result = await octokit.graphql(`query { \r\n                viewer { \r\n                  login\r\n                }\r\n            }`)\r\n            console.log(result)\r\n```\r\n\r\n### graphql-request\r\nSee [npmjs.com/package/graphql-request](https://www.npmjs.com/package/graphql-request).\r\n```js\r\nimport { request, gql } from 'graphql-request'\r\n\r\nrequest({\r\n    url: 'https://api.github.com/graphql',\r\n    document: gql`{ \r\n        viewer { \r\n          login\r\n        }\r\n    }`,\r\n    requestHeaders: {\r\n        Authorization: `bearer ${process.env.GITHUB_TOKEN}`\r\n    }\r\n}).then((data) =\u003e console.log(data))\r\n```\r\n\r\n### Apollo\r\n[apollo/client](https://www.npmjs.com/package/@apollo/client) is very popular and primarily for the web. It is heavly used for React projects.\r\n\r\nHere is a NodeJS implementation.\r\n```js\r\nimport { ApolloClient, InMemoryCache, gql, HttpLink } from \"@apollo/client/core\";\r\nimport { setContext } from '@apollo/link-context';\r\nimport fetch from 'cross-fetch';\r\n\r\nconst httpLink = new HttpLink({\r\n    uri: 'https://api.github.com/graphql',\r\n    fetch\r\n});\r\n\r\nconst authLink = setContext((_, { headers }) =\u003e {\r\n    return {\r\n        headers: {\r\n            ...headers,\r\n            authorization: `bearer ${process.env.GITHUB_TOKEN}`\r\n        }\r\n    }\r\n});\r\n\r\nconst client = new ApolloClient({\r\n    cache: new InMemoryCache(),\r\n    link: authLink.concat(httpLink)\r\n});\r\n\r\nclient.query({\r\n    query: gql`{ \r\n        viewer { \r\n          login\r\n        }\r\n    }`\r\n}).then(result =\u003e console.log(result.data));\r\n```\r\n\r\n## Code Generation\r\n\r\n### Graphql Code Generator\r\n[graphql-code-generator](https://www.graphql-code-generator.com/) has [plugins](https://www.graphql-code-generator.com/plugins) to generate code for most languages.\r\n\r\n# Want to learn more?\r\n\r\nSee [Advanced patterns for GitHub's GraphQL API](https://youtu.be/i5pIszu9MeM)\u003cbr\u003e\r\n\u003ca href=\"https://youtu.be/i5pIszu9MeM\"\u003e\r\n  \u003cimg src=\"https://img.youtube.com/vi/i5pIszu9MeM/maxresdefault.jpg\" width=\"300px\"\u003e\r\n\u003c/a\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustenstone%2Fgh-api-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faustenstone%2Fgh-api-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustenstone%2Fgh-api-graphql/lists"}