# node-github-graphql

> GitHub graphql HTTP wrapper

Latest version **0.2.7** (published 2018-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-github-graphql
pnpm add node-github-graphql
yarn add node-github-graphql
bun add node-github-graphql
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.7 |
| Published | 2018-06-21 |
| First published | 2017-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 4 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Wilson Ching |
| Maintainers | wilsonchingg |
| Keywords | heroku |

## Links

- npm: https://www.npmjs.com/package/node-github-graphql
- Repository: https://github.com/wilsonchingg/node-github-graphql
- Homepage: https://github.com/wilsonchingg/node-github-graphql#readme
- Issues: https://github.com/wilsonchingg/node-github-graphql/issues
- npm.io page: https://npm.io/package/node-github-graphql

## Dependencies (4)

- [request](https://npm.io/package/request.md) ^2.81.0
- [winston](https://npm.io/package/winston.md) ^2.3.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.0
- [https-proxy-agent](https://npm.io/package/https-proxy-agent.md) ^2.2.1

## Recent versions

- 0.2.7 (latest) — 2018-06-21
- 0.2.6 — 2017-08-15
- 0.2.4 — 2017-05-31
- 0.2.3 — 2017-05-30
- 0.2.2 — 2017-05-30
- 0.2.1 — 2017-05-30
- 0.2.0 — 2017-05-30

## README

## Node-Github-GraphQL

A GitHub GraphQL HTTP wrapper

### Table of contents

- [Node-Github-GraphQL](#node-github-graphql)
  * [Table of contents](#table-of-contents)
  * [Installation](#installation)
  * [Basic Example](#basic-example)
  * [Advanced Example](#advanced-example)
  * [API Reference](#api-reference)
  * [LICENSE](#license)

### Installation

```
npm install node-github-graphql --save
```

### Basic Example

```javascript
var GithubGraphQLApi = require('node-github-graphql')
var github = new GithubGraphQLApi({
  token: process.env.GITHUB_API_TOKEN
})
github.query(`
{
	viewer {
	  login
	}
}
`, null, (res, err) => {
  console.log(JSON.stringify(res, null, 2))
})
```

### Advanced Example

```javascript
var GithubGraphQLApi = require('node-github-graphql')
var github = new GithubGraphQLApi({
  Promise: require('bluebird'),
  token: process.env.GITHUB_API_TOKEN,
  userAgent: 'Hello', // Optional, if not specified, a default user agent will be used
  debug: true
})
github.query(`
query ($number_of_commits: Int!) {
  repository(name: "node-github-graphql", owner: "wilsonchingg") {
    ref(qualifiedName: "master") {
      target {
        ...handleCommits
      }
    }
  }
}

fragment handleCommits on Commit {
  id
  history(first: $number_of_commits) {
    edges {
      node {
        author {
          name
          date
        }
      }
    }
  }
}`, {
  'number_of_commits': 3
}
).then(function (res) {
  console.log(JSON.stringify(res, null, 2))
}).catch((err) => { console.log(err) })
```

### API Reference

#### new GithubGraphQLApi(options) ####

**- options**

Type: objects

The accepted keys are as below:


| Key             | Value                               |
|-----------------|-------------------------------------|
| Promise/promise | The promise object                  |
| token           | Github API key(**Mandatory**)       |
| debug           | To turn on debug log (boolean)      |
| userAgent       | User-Agent if specified             |
| url             | Alternative url to send the request |

#### github.request(query, variables, callback) ####

**- query**

Type: string

GraphQL query

**- variables (optional)**

Type: object

Dynamic arguments to be passed inside the query string. See http://graphql.org/learn/queries/#variables

**- callback (optional)**

Type: function (string response, string error)

If callback is specified, it will be used instead of promises.

### LICENSE

MIT license. See the LICENSE file for details.

---
_Source: https://npm.io/package/node-github-graphql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
