Starter template for querying GitHub's GQL API using Node
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
GitHub GraphQL API client for browsers and Node
Clone this repo.
$ git clone [email protected]:MichaelCurrin/github-gql-js.git
$ cd github-gql-js
Install Node.js - see gist.
You also need make
- standard on Linux and macOS. Otherwise run the commands directly in Makefile.
$ make install
- Create a GitHub API token with appropriate permissions
- Copy the token value. Keep this secret and out of version control.
- Create a dotfile based on the template. This config file will be ignored by Git.
$ cp .env.template .env
- Paste your token in the file.
$ make run
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).
- V4 GraphQL in Dev Resources
- https://github.com/MichaelCurrin/github-gql-go - built with Go.
- https://github.com/MichaelCurrin/github-reporting-py - built with Python.
Released under MIT by @MichaelCurrin.