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';
You can also import query and fragment documents by name.
query MyQuery1 {
...
}
query MyQuery2 {
...
}
And in your JavaScript:
import { MyQuery1, MyQuery2 } from 'query.graphql';
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'
}
],
...
}