New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-github-graphql

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-github-graphql

GitHub graphql HTTP wrapper

0.2.7
latest
Source
npm
Version published
Maintainers
1
Created
Source

Node-Github-GraphQL

A GitHub GraphQL HTTP wrapper

Table of contents

  • Node-Github-GraphQL

Installation

npm install node-github-graphql --save

Basic Example

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

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:

KeyValue
Promise/promiseThe promise object
tokenGithub API key(Mandatory)
debugTo turn on debug log (boolean)
userAgentUser-Agent if specified
urlAlternative 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.

Keywords

heroku

FAQs

Package last updated on 21 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts