
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
@jorritschippers/webpack-graphql-loader
Advanced tools
A webpack loader for .graphql
query documents with first class support for schema validation and fragments definitions.
This is a fork of webpack-graphql-loader. The differences are:
DocumentNode
AST. Only output as string is supported.yarn add --dev @jorritschippers/webpack-graphql-loader # or npm install --save-dev @jorritschippers/webpack-graphql-loader
You will also need to install a copy of graphql
, which is a peer dependency of this package.
yarn add --dev graphql # or npm install --save-dev graphql
Add @jorritschippers/webpack-graphql-loader
to your webpack configuration:
module.exports = {
// ...
module: {
rules: [ // or "loaders" for webpack 1.x
{ test: /\.graphql?$/, loader: '@jorritschippers/webpack-graphql-loader' }
]
}
}
You can also pass options to the loader via webpack options:
module.exports = {
// ...
module: {
rules: [ // or "loaders" for webpack 1.x
{
test: /\.graphql?$/,
use: [
{
loader: 'webpack-graphql-loader',
options: {
// validate: true,
// schema: "./path/to/schema.json",
// removeUnusedFragments: true
// etc. See "Loader Options" below
}
}
]
}
]
}
}
The location of your graphql introspection query schema JSON file. If used with the validate
option, this will be used to validate imported queries and fragments.
If true
, the loader will validate the imported document against your specified schema
file.
If true
and the output
option is string
, the loader will strip comments and whitespace from the graphql document strings. This helps to reduce bundled code size.
If true
, the loader will remove unused fragments from the imported document. This may be useful if a query is importing fragments from a file, but does not use all fragments in that file. Also see this issue.
.graphql
filesThe loader supports importing .graphql
files from other .graphql
files using an #import
statement. For example:
query.graphql
:
#import "./fragments.graphql"
query {
...a
...b
}
fragments.graphql
:
fragment a on A {}
fragment b on A {
foo(bar: 1)
}
In the above example, fragments a
and b
will be made available within query.graphql
. Note that all fragments in the imported file should be used in the top-level query, or the removeUnusedFragments
should be specified.
FAQs
webpack graphql loader
The npm package @jorritschippers/webpack-graphql-loader receives a total of 13 weekly downloads. As such, @jorritschippers/webpack-graphql-loader popularity was classified as not popular.
We found that @jorritschippers/webpack-graphql-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.