gatsby-plugin-graphql-tag-loader

1.0.1 • Public • Published

gatsby-plugin-graphql-tag-loader

Gatsby plugin for importing .graphql and .gql directly into js using graphql-tag/loader.

Install

$ yarn add gatsby-plugin-graphql-tag-loader

or

$ npm i --save gatsby-plugin-graphql-tag-loader

How to use

Simply add the plugin to your gatsby-config.js.

{
  plugins: [`gatsby-plugin-graphql-tag-loader`];
}

or use custom options

{
  plugins: [
    {
      resolve: `gatsby-plugin-graphql-tag-loader`,
      options: {
        exclude: /node_modules/, // default exclude value
        test: /\.(graphql|gql)$/, // default test value
      },
    },
  ];
}

Example

gatsby-config.js

{
  plugins: [`gatsby-plugin-graphql-tag-loader`];
}

currentUser.gql

query CurrentUserForLayout {
  currentUser {
    login
    avatar_url
  }
}

twoQueries.graphql

query MyQuery1 {
  ...
}

query MyQuery2 {
  ...
}

index.js

import currentUserQuery from "./currentUser.gql";
import { MyQuery1, MyQuery2 } from "./twoQueries.graphql";

Package Sidebar

Install

npm i gatsby-plugin-graphql-tag-loader

Weekly Downloads

98

Version

1.0.1

License

MIT

Unpacked Size

3.82 kB

Total Files

9

Last publish

Collaborators

  • garox