{"id":20630706,"url":"https://github.com/sysgears/graphql-codegen-webpack-plugin","last_synced_at":"2026-05-01T21:33:44.621Z","repository":{"id":66053088,"uuid":"155530445","full_name":"sysgears/graphql-codegen-webpack-plugin","owner":"sysgears","description":"Webpack Plugin for graphql-code-generator","archived":false,"fork":false,"pushed_at":"2018-11-08T15:06:52.000Z","size":215,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-11T01:08:09.051Z","etag":null,"topics":["codegen","graphql","plugin","webpack"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sysgears.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-10-31T09:23:18.000Z","updated_at":"2019-08-07T08:30:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"6754da3e-3285-4312-a561-dbf5de6239e0","html_url":"https://github.com/sysgears/graphql-codegen-webpack-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sysgears/graphql-codegen-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fgraphql-codegen-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fgraphql-codegen-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fgraphql-codegen-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fgraphql-codegen-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysgears","download_url":"https://codeload.github.com/sysgears/graphql-codegen-webpack-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fgraphql-codegen-webpack-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32513721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codegen","graphql","plugin","webpack"],"created_at":"2024-11-16T14:09:20.139Z","updated_at":"2026-05-01T21:33:44.584Z","avatar_url":"https://github.com/sysgears.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL Code Genenerator Webpack Plugin\n\n[![Build Status](https://travis-ci.org/sysgears/graphql-codegen-webpack-plugin.svg?branch=master)](https://travis-ci.org/sysgears/graphql-codegen-webpack-plugin)\n[![Greenkeeper badge](https://badges.greenkeeper.io/sysgears/graphql-codegen-webpack-plugin.svg)](https://greenkeeper.io/) [![Twitter Follow](https://img.shields.io/twitter/follow/sysgears.svg?style=social)](https://twitter.com/sysgears)\n\nWebpack Plugin for [graphql-code-generator](https://github.com/dotansimha/graphql-code-generator)\n\n## Installation\n\n```bash\nnpm install --save-dev graphql-codegen-webpack-plugin\n```\n\n## Usage\n\n### When Webpack is used for front-end only\n\nSample Webpack config:\n\n```js\nvar graphqlCodegenPlugin = require('graphql-codegen-webpack-plugin');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(graphql|gql)$/,\n        use: 'graphql-tag/loader'\n      },\n    ]\n  }\n\n  plugins: [\n    new graphqlCodegenPlugin({filename: 'persisted_queries.json',\n        moduleName: path.resolve('node_modules/persisted_queries.json')})\n  ]\n};\n```\n\nIn the source code of front-end persisted GraphQL queries will be injected\nas a virtual module `persisted_queries.json`. This module will be updated\nif queries added or changed. Also asset with name `persisted_queries.json` will be generated\nduring compilation and written to output directory.\n\n```js\nvar queryMap = require('persisted_queries.json');\nconsole.log(queryMap);\n```\n\n### When Webpack is used both for back-end and front-end\n\n```js\nvar graphqlCodegenPlugin = require('graphql-codegen-webpack-plugin');\n\nconst moduleName = path.resolve('node_modules/persisted_queries.json');\nconst frontendPersistPlugin = new graphqlCodegenPlugin({ moduleName });\nconst backendPersistPlugin =\n    new graphqlCodegenPlugin({ provider: clientPersistPlugin, moduleName });\n\nvar frontendWebpackConfig = {\n  module: {\n    rules: [\n      {\n        test: /\\.(graphql|gql)$/,\n        use: 'graphql-tag/loader'\n      },\n    ]\n  }\n\n  plugins: [\n    frontendPersistPlugin\n  ]\n};\n\nvar backendWebpackConfig = {\n  // ...\n  plugins: [\n    backendPersistPlugin\n  ]\n}\n```\n\nBoth in the source code of front-end and back-end persisted GraphQL queries will be injected\nas a virtual module `node_modules/persisted_queries.json`. This module will be updated if queries added or changed.\n\n```js\nvar queryMap = require('persisted_queries.json');\nconsole.log(queryMap);\n```\n\n|Name|Type|Description|\n|:--:|:--:|:----------|\n|**`moduleName`**|`{String}`|Name of virtual wepback module with persisted GraphQL queries, this option is **required**|\n|**`filename`**|`{String}`|Name of the ouput file with persisted GraphQL queries|\n|**`addTypename`**|`{Boolean}`|Apply a query transformation to the query documents, adding the __typename field at every level of the query, default: `true`|\n|**`hashQuery`**|`{Function}`|Function to hash queries in hash map, default: SHA-256 from query, if `false` passed - counter values are used|\n|**`provider`**|`{Object}`|Instance of plugin running on another webpack instance which will provide persisted GraphQL queries|\n|**`excludeRegex`**|`{RegExp}`|RegExp to match file path that will be excluded from processing by the plugin, default: `/[\\\\/]node_modules[\\\\/]/`|\n|**`graphqlRegex`**|`{RegExp}`|RegExp to match files loaded by `graphql-tag/loader` that should be processed by the plugin, default: `/(.graphql\\|.gql)$/`|\n|**`jsRegex`**|`{RegExp}`|RegExp to match js files that have embedded GraphQL queries marked with `gql` tag, default: `/(.jsx?\\|.tsx?)$/`|\n\n## License\nCopyright © 2018 [SysGears Limited]. This source code is licensed under the [MIT] license.\n\n[MIT]: LICENSE\n[SysGears Limited]: http://sysgears.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysgears%2Fgraphql-codegen-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysgears%2Fgraphql-codegen-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysgears%2Fgraphql-codegen-webpack-plugin/lists"}