npm.io
3.1.0 • Published 1 month ago

@graphql-tools/jest-transform

Licence
MIT
Version
3.1.0
Deps
4
Size
5 kB
Vulns
0
Weekly
0
Stars
5.4K

GraphQL Jest Transform

A Jest transformer to preprocess GraphQL Documents (operations, fragments and SDL)

npm install @graphql-tools/jest-transform

In your package.json:

{
  "jest": {
    "transform": {
      "\\.(gql|graphql)$": "@graphql-tools/jest-transform"
    }
  }
}

or jest.config.js:

module.exports = {
  // ...
  transform: {
    '\\.(gql|graphql)

How is it different from jest-transform-graphql? It doesn't use graphql-tag/loader under the hood but our own, more optimized and customisable @graphql-tools/webpack-loader. A .graphql file may export more than one named operation; see the webpack-loader README.

Options

  • noDescription (default: false) - removes descriptions
  • esModule (default: false) - uses import and export statements instead of CommonJS
{
  "globals": {
    "graphql": {
      "noDescription": true
    }
  }
}
: '@graphql-tools/jest-transform' } }

How is it different from __INLINE_CODE_2__? It doesn't use __INLINE_CODE_3__ under the hood but our own, more optimized and customisable __INLINE_CODE_4__. A __INLINE_CODE_5__ file may export more than one named operation; see the webpack-loader README.

Options

  • noDescription (default: false) - removes descriptions
  • esModule (default: false) - uses import and export statements instead of CommonJS
__CODE_BLOCK_3__