Socket
Socket
Sign inDemoInstall

gatsby-source-graphql

Package Overview
Dependencies
Maintainers
1
Versions
357
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-source-graphql

A Gatsby source plugin for pulling in data from GraphQL APIs.


Version published
Weekly downloads
21K
increased by11.14%
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-source-graphql

Build Status npm Codecov.io

A Gatsby source plugin for pulling in data from GraphQL APIs.

Installation

Yarn

$ yarn add --dev gatsby-source-graphql

npm

$ npm install --save-dev gatsby-source-graphql

Usage

With gatsby-source-filesystem

// gatsby-config.js

// Optionally pull in environment variables
require('dotenv').config({
  path: `.env.${process.env.NODE_ENV}`,
});

module.exports = {
  // ...
  plugins: [
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'queries',
        path: `${__dirname}/src/queries/`,
      },
    },
    {
      resolve: 'gatsby-source-graphql',
      options: {
        headers: {
          authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
        },
        url: 'https://api.github.com/graphql',
      },
    },
  ]
}
# src/queries/github.graphql
{
  viewer {
    name
    url
  }
}

How to query

Given the above example with a GraphQL file named github.graphql, you would query Gatsby like so:

query GitHubViewerQuery {
  githubGraphQl {
    viewer {
      name
      url
    }
  }
}

Change Log

Full Change Log

v1.1.0 (2018-06-05)

  • [67d99754ad] - Allow a promise for asynchronously loading options (#4) (Judah Anthony)
  • [4471e2c221] - Improve usage instructions (#3) (Tomasz Radziejewski)

License

MIT © Neil Kistner

Keywords

FAQs

Package last updated on 05 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

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