{"id":13452604,"url":"https://github.com/samsarahq/graphql-loader","last_synced_at":"2026-01-25T07:46:43.159Z","repository":{"id":23027289,"uuid":"97970550","full_name":"samsarahq/graphql-loader","owner":"samsarahq","description":":cherries: A webpack loader for .graphql documents","archived":false,"fork":false,"pushed_at":"2022-12-06T19:59:15.000Z","size":294,"stargazers_count":62,"open_issues_count":35,"forks_count":15,"subscribers_count":47,"default_branch":"master","last_synced_at":"2025-09-28T10:56:31.979Z","etag":null,"topics":["graphql","webpack","webpack-loader"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samsarahq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-21T17:09:55.000Z","updated_at":"2025-08-25T16:38:45.000Z","dependencies_parsed_at":"2023-01-13T22:38:19.338Z","dependency_job_id":null,"html_url":"https://github.com/samsarahq/graphql-loader","commit_stats":null,"previous_names":["stephen/graphql-loader"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/samsarahq/graphql-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsarahq%2Fgraphql-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsarahq%2Fgraphql-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsarahq%2Fgraphql-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsarahq%2Fgraphql-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samsarahq","download_url":"https://codeload.github.com/samsarahq/graphql-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samsarahq%2Fgraphql-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28748254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T05:12:38.112Z","status":"ssl_error","status_checked_at":"2026-01-25T05:04:50.338Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["graphql","webpack","webpack-loader"],"created_at":"2024-07-31T07:01:28.931Z","updated_at":"2026-01-25T07:46:43.136Z","avatar_url":"https://github.com/samsarahq.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# GraphQL Loader for Webpack\n\n[![npm Version](https://img.shields.io/npm/v/webpack-graphql-loader.svg)](https://www.npmjs.com/package/webpack-graphql-loader)\n[![Build Status](https://api.travis-ci.org/samsarahq/graphql-loader.svg?branch=master)](https://travis-ci.org/samsarahq/graphql-loader)\n\nA webpack loader for `.graphql` query documents with first class support for **schema validation** and **fragments definitions**. `graphql-loader` works great with [thunder](https://github.com/samsarahq/thunder), [apollo-client](#output-string--document-defaultstring), and anywhere you might want to provide a GraphQL query document in the frontend.\n\n## Installation\n\n```bash\nyarn add --dev webpack-graphql-loader # or npm install --save-dev webpack-graphql-loader\n```\n\nYou will also need to install a copy of [`graphql`](https://www.npmjs.com/package/graphql), which is a peer dependency of this package.\n\n```bash\nyarn add --dev graphql # or npm install --save-dev graphql\n```\n\n\n## Configuration\n\nAdd `webpack-graphql-loader` to your webpack configuration:\n```javascript\nmodule.exports = {\n  // ...\n  module: {\n    rules: [ // or \"loaders\" for webpack 1.x\n      { test: /\\.graphql?$/, loader: 'webpack-graphql-loader' }\n    ]\n  }\n}\n```\n\n### Specifying options\nYou can also pass options to the loader via webpack options:\n```javascript\nmodule.exports = {\n  // ...\n  module: {\n    rules: [ // or \"loaders\" for webpack 1.x\n      {\n        test: /\\.graphql?$/,\n        use: [\n          {\n            loader: 'webpack-graphql-loader',\n            options: {\n              // validate: true,\n              // schema: \"./path/to/schema.json\",\n              // removeUnusedFragments: true\n              // etc. See \"Loader Options\" below\n            }\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\n### Loader Options\n\n#### schema _(string) (default=\"\")_\n\nThe 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.\n\n#### validate _(boolean) (default=false)_\n\nIf `true`, the loader will validate the imported document against your specified `schema` file.\n\n#### output _(\"string\" | \"document\") (default=\"string\")_\n\nSpecifies whether or not the imported document should be a printed graphql string, or a graphql `DocumentNode` AST. The latter is useful for interop with [`graphql-tag`](https://github.com/apollographql/graphql-tag#webpack-preprocessing).\n\n#### minify _(boolean) (default=false)_\n\nIf `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.\n\n#### removeUnusedFragments _(boolean) (default=false)_\n\nIf `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](https://github.com/apollographql/graphql-tag/issues/102).\n\n## Import statements in `.graphql` files\n\nThe loader supports importing `.graphql` files from other `.graphql` files using an `#import` statement. For example:\n\n`query.graphql`:\n```graphql\n#import \"./fragments.graphql\"\n\nquery {\n  ...a\n  ...b\n}\n```\n\n`fragments.graphql`:\n```graphql\nfragment a on A {}\nfragment b on A {\n  foo(bar: 1)\n}\n```\n\nIn 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.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsarahq%2Fgraphql-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamsarahq%2Fgraphql-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamsarahq%2Fgraphql-loader/lists"}