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

gatsby-source-github-api

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-source-github-api

gatsby plugin for github v4 API

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
536
decreased by-12.13%
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-source-github

Source plugin for pulling data into Gatsby from the official Github v4 graphQL API.

Install

npm install --save gatsby-source-github

How to use

Follow Github's guide to generate a token

Once you are done, either create a gatsby-config.js file or open the one you already have.

In there, you want to add this plugin and at least add the token in the options object:

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-github`,
    options: {
      // token required by the Github API
      token: someString = undefined, //required
      // graphQL query
      // defaults to a search query. See below
      graphQLQuery: anotherString,
      // graphQL variables
      // defaults to variables needed for a
      // search query. See below
      variables: someObject
    }
  }
]

Examples (How to use)

Simple search query

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-github`,
    options: {
      token: 'hunter2',
      variables: {
        q: "author:ldd state:closed type:pr sort:comments",
        nFirst: 2
      }
    }
  }
]

resulting API call:

  query ($nFirst: Int, $q: String) {
    search(query: "${q}", type: ISSUE, first: ${nFirst}){
      edges{
        node{
          ... on PullRequest{
            title
          }
        }
      }
    }
  }

generic graphQL query

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-github`,
    options: {
      token: 'hunter2',
      variables: {},
      graphQLQuery: `
        query {
          repository(owner:"torvalds",name:"linux"){
            description
          }
        }
        `
    }
  }
]

resulting API call:

  query {
    repository(owner:"torvalds", name:"linux"){
      description
    }
  }

Changelog

v0.0.2 Include a link to github in package.json

v0.0.1 Initial Release

Keywords

FAQs

Package last updated on 10 Sep 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc