{"id":14976159,"url":"https://github.com/ldd/gatsby-source-github-api","last_synced_at":"2025-03-30T00:30:30.519Z","repository":{"id":25026732,"uuid":"103008282","full_name":"ldd/gatsby-source-github-api","owner":"ldd","description":"Pull data into Gatsby from Github API v4","archived":false,"fork":false,"pushed_at":"2023-01-06T02:15:51.000Z","size":1092,"stargazers_count":65,"open_issues_count":13,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T08:48:56.281Z","etag":null,"topics":["gatsby","github","github-api","graphql-queries","graphql-query","javascript"],"latest_commit_sha":null,"homepage":"","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/ldd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-10T06:16:58.000Z","updated_at":"2023-12-05T13:42:49.000Z","dependencies_parsed_at":"2023-01-14T02:00:05.580Z","dependency_job_id":null,"html_url":"https://github.com/ldd/gatsby-source-github-api","commit_stats":null,"previous_names":["ldd/gatsby-source-github"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldd%2Fgatsby-source-github-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldd%2Fgatsby-source-github-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldd%2Fgatsby-source-github-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldd%2Fgatsby-source-github-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ldd","download_url":"https://codeload.github.com/ldd/gatsby-source-github-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262490,"owners_count":20749170,"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":["gatsby","github","github-api","graphql-queries","graphql-query","javascript"],"created_at":"2024-09-24T13:53:24.513Z","updated_at":"2025-03-30T00:30:30.494Z","avatar_url":"https://github.com/ldd.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.com/ldd/gatsby-source-github-api.svg?branch=master)](https://travis-ci.com/ldd/gatsby-source-github-api)\n[![Coverage Status](https://coveralls.io/repos/github/ldd/gatsby-source-github-api/badge.svg?branch=master)](https://coveralls.io/github/ldd/gatsby-source-github-api?branch=master)\n\n# gatsby-source-github-api\n\nSource plugin for pulling data into Gatsby from the official GitHub v4 [GraphQL API](https://developer.github.com/v4/).\n\n## Install\n\n`npm i gatsby-source-github-api`\n\n## How to use\n\nFollow GitHub's guide [how to generate a token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/).\n\nOnce you are done, either create a `gatsby-config.js` file or open the one you already have.\n\nIn there, you want to add this plugin and at least add the token in the options object:\n\n```javascript\n// In your gatsby-config.js\nplugins: [\n  {\n    resolve: `gatsby-source-github-api`,\n    options: {\n      // url: API URL to use. Defaults to  https://api.github.com/graphql\n      url: someUrl,\n\n      // token: required by the GitHub API\n      token: someString,\n\n      // GraphQLquery: defaults to a search query\n      graphQLQuery: anotherString,\n\n      // variables: defaults to variables needed for a search query\n      variables: someObject\n    }\n  }\n];\n```\n\n## Examples\n\n**Search query:**\n\n```javascript\n// In your gatsby-config.js\nplugins: [\n  {\n    resolve: `gatsby-source-github-api`,\n    options: {\n      token: \"hunter2\",\n      variables: {\n        q: \"author:ldd state:closed type:pr sort:comments\",\n        nFirst: 2\n      }\n    }\n  }\n];\n```\n\nresulting API call:\n\n```graphql\n  query ($nFirst: Int, $q: String) {\n    search(query: \"${q}\", type: ISSUE, first: ${nFirst}){\n      edges{\n        node{\n          ... on PullRequest{\n            title\n          }\n        }\n      }\n    }\n  }\n```\n\n**Custom GraphQL query:**\n\n```javascript\n// In your gatsby-config.js\nplugins: [\n  {\n    resolve: `gatsby-source-github-api`,\n    options: {\n      token: \"hunter2\",\n      variables: {},\n      graphQLQuery: `\n        query {\n          repository(owner:\"torvalds\",name:\"linux\"){\n            description\n          }\n        }\n        `\n    }\n  }\n];\n```\n\nresulting API call:\n\n```graphql\nquery {\n  repository(owner: \"torvalds\", name: \"linux\") {\n    description\n  }\n}\n```\n\nFor more examples see [gatsby-starter-github-portfolio](https://github.com/ldd/gatsby-starter-github-portfolio).\n\n## Tips and Tricks\n\nYou'll probably want to use valid GraphQL queries. To help you, GitHub has a [Query Explorer](https://developer.github.com/v4/explorer/) with auto-completion.\n\n![Query Explorer](https://user-images.githubusercontent.com/1187476/30273078-69695a10-96c5-11e7-90b8-7dc876cc214a.png)\n\n## Changelog\n\n- `v1.0.0` add support for gatsby v3. Remove support for older versions of gatsby\n- `v0.2.1` update dependencies\n- `v0.2.0` provide raw github response\n- `v0.1.5` document url option (for GitHub Enterprise users)\n- `v0.1.4`\n  - Add tests\n  - expose DEFAULT_QUERY by exporting it\n- `v0.1.3`\n  - Change mediaType of exported node to be ignored by `gatsby-transformer-json`\n  - prettify changelog of this file\n- `v0.1.2` Updated `yarn.lock` to address github security warnings\n- `v0.1.1` Updated Readme for easier usage\n- `v0.1.0` Submit to Gatsby's Plugin Library\n- `v0.0.4` Update dev dependencies, add linting script to package.json\n- `v0.0.3` Initial public release\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldd%2Fgatsby-source-github-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fldd%2Fgatsby-source-github-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldd%2Fgatsby-source-github-api/lists"}