Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.03 KB

README.md

File metadata and controls

49 lines (36 loc) · 1.03 KB

@evo/graphql-tag-loader

More optimized loader for lib graphql-tag:

If you have configured the webpack @evo/graphql-tag-loader, you can import modules containing graphQL queries. The imported value will be the pre-built AST.

import MyQuery from 'query.graphql';

Importing queries by name

You can also import query and fragment documents by name.

query MyQuery1 {
  ...
}

query MyQuery2 {
  ...
}

And in your JavaScript:

import { MyQuery1, MyQuery2 } from 'query.graphql';

Webpack loading and preprocessing

Using the included @evo/graphql-tag-loader it is possible to maintain query logic that is separate from the rest of your application logic. With the loader configured, imported graphQL files will be converted to AST during the webpack build process.

Example webpack configuration

{
  ...
  loaders: [
    {
      test: /\.(graphql|gql)$/,
      exclude: /node_modules/,
      loader: '@evo/graphql-tag-loader'
    }
  ],
  ...
}