https://github.com/michaelcurrin/github-gql-js
Starter template for querying GitHub's GQL API using Node
https://github.com/michaelcurrin/github-gql-js
github-graphql github-v4 gql javascript nodejs
Last synced: 11 months ago
JSON representation
Starter template for querying GitHub's GQL API using Node
- Host: GitHub
- URL: https://github.com/michaelcurrin/github-gql-js
- Owner: MichaelCurrin
- License: mit
- Created: 2021-10-25T15:20:26.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-11T12:42:25.000Z (over 3 years ago)
- Last Synced: 2025-01-14T20:52:46.785Z (12 months ago)
- Topics: github-graphql, github-v4, gql, javascript, nodejs
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHub GraphQL JS
> Starter template for querying GitHub's GQL API using Node
[](https://github.com/MichaelCurrin/github-gql-js/releases/)
[](#license)
[](https://nodejs.org)
[](https://www.npmjs.com/package/@octokit/graphql)
[](https://github.com/MichaelCurrin/github-gql-js/generate)
## About
This repo demonstrates how to query GitHub's GraphQL API using Node.
The `graphql` NPM package is used. The content is based on the documentation here:
- [octokit/graphql.js](https://github.com/octokit/graphql.js)
> GitHub GraphQL API client for browsers and Node
## Installation
### Clone
Clone this repo.
```sh
$ git clone git@github.com:MichaelCurrin/github-gql-js.git
$ cd github-gql-js
```
### Install system packages
Install Node.js - see [gist](https://gist.github.com/aa1fc56419a355972b96bce23f3bccba).
You also need `make` - standard on Linux and macOS. Otherwise run the commands directly in [Makefile](/Makefile).
### Install project packages
```sh
$ make install
```
## Configuration
1. Create a GitHub API token with appropriate permissions
- https://github.com/settings/tokens
1. Copy the token value. Keep this **secret** and out of version control.
1. Create a dotfile based on the template. This config file will be ignored by Git.
```sh
$ cp .env.template .env
```
1. Paste your token in the file.
## Usage
```sh
$ make run
```
## More info
### GitHub APIs and tokens
GitHub GQL queries require an **API** token, unlike the REST API which does not.
Avoid using the **browser** to do your GQL queries - you'll risk exposing your token to others on the internet.
Rather run your logic using **Node** on a server or in a serverless function (AWS Lambda or [Netlify Functions][]).
[Netlify Functions]: https://michaelcurrin.github.io/dev-resources/resources/ci-cd/netlify/functions.html
### Resources
- [V4 GraphQL](https://michaelcurrin.github.io/dev-resources/resources/version-control/github/api/v4.html) in Dev Resources
### Related
- https://github.com/MichaelCurrin/github-gql-go - built with Go.
- https://github.com/MichaelCurrin/github-reporting-py - built with Python.
## License
Released under [MIT](/LICENSE) by [@MichaelCurrin](https://github.com/MichaelCurrin).