graphql-codegen-webpack
TypeScript icon, indicating that this package has built-in type declarations

0.13.0 • Public • Published

graphql-codegen-webpack

Integrates GraphQL Code Generator with Webpack

const { GraphQLCodegenPlugin } = require('graphql-codegen-webpack');
 
new GraphQLCodegenPlugin({
  schema: 'src/schema.graphql',
  template: 'graphql-codegen-typescript-template',
  out: 'src/types.ts',
  overwrite: true
});

Full example of webpack configuration:

const { GraphQLCodegenPlugin } = require('graphql-codegen-webpack');
 
module.exports = {
  mode: 'development',
  devtool: 'inline-source-map',
  entry: './src/index.ts',
  output: {
    filename: 'bundle.js'
  },
  resolve: {
    extensions: ['.ts', '.ts', '.js', '.mjs']
  },
  plugins: [
    // GraphQL Code Generator
    new GraphQLCodegenPlugin({
      schema: 'src/schema.graphql',
      template: 'graphql-codegen-typescript-template',
      out: 'src/types.ts',
      overwrite: true
    })
  ],
  module: {
    rules: [
      { test: /\.ts$/, loader: 'ts-loader' },
      {
        test: /\.mjs$/,
        include: /node_modules/,
        type: 'javascript/auto'
      }
    ]
  }
};

Dependents (0)

Package Sidebar

Install

npm i graphql-codegen-webpack

Weekly Downloads

161

Version

0.13.0

License

MIT

Unpacked Size

19.3 kB

Total Files

17

Last publish

Collaborators

  • dotansimha
  • kamilkisiela