Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@sewing-kit/graphql
Advanced tools
This package provides transformers for importing .graphql files in various build tools.
@sewing-kit/graphql
This package provides transformers for importing .graphql files in various build tools.
yarn add @sewing-kit/graphql --dev
This package provides a loader for .graphql
files in Webpack. This loader automatically minifies and adds a unique identifier to each GraphQL document.
To use this loader in Webpack, add a rule referencing this loader to your Webpack configuration:
module.exports = {
module: {
rules: [
{
test: /\.graphql$/,
use: '@sewing-kit/graphql/webpack',
exclude: /node_modules/,
},
],
},
};
Note that, unlike graphql-tag/loader
, this loader does not currently support exporting multiple operations from a single file. You can, however, import other GraphQL documents containing fragments with #import
comments at the top of the file:
#import './ProductVariantPriceFragment.graphql';
query Product {
product {
variants(first: 10) {
edges {
node {
...ProductVariantId
...ProductVariantPrice
}
}
}
}
}
fragment ProductVariantId on ProductVariant {
id
}
This loader accepts a single option, export
. This option controls the shape of the value exported from GraphQL files. By default, a graphql
DocumentNode
is exported. However, setting export: 'simple'
will instead export a representation of the document that contains only the source
, operationNode
, and unique id
for the document. This representation of GraphQL documents is smaller than a full DocumentNode
, but generally won’t work with normalized GraphQL caches.
module.exports = {
module: {
rules: [
{
test: /\.(graphql|gql)$/,
use: '@sewing-kit/graphql/webpack',
exclude: /node_modules/,
options: {export: 'simple'},
},
],
},
};
If this option is set to true
, you should also use the jest-simple
transformer for Jest, and the --export-format simple
flag for graphql-typescript-definitions
.
This package also provides a transformer for GraphQL files in Jest. To use the transformer, add a reference to it in your Jest configuration’s transform
option:
module.exports = {
transform: {
'\\.graphql$': '@sewing-kit/graphql/jest',
},
};
If you want to get the same output as the simple
option of the webpack loader, you can instead use the jest-simple
loader transformer:
module.exports = {
transform: {
'\\.graphql$': '@sewing-kit/graphql/jest-simple',
},
};
This loader takes heavy inspiration from the following projects:
We wrote something custom in order to get the following benefits:
FAQs
Graphql transformers
We found that @sewing-kit/graphql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.