{"id":18165528,"url":"https://github.com/hikiko4ern/swc-plugin-minify-graphql","last_synced_at":"2026-02-09T17:36:35.854Z","repository":{"id":259134634,"uuid":"873049539","full_name":"hikiko4ern/swc-plugin-minify-graphql","owner":"hikiko4ern","description":"GraphQL query and schema minimizer plugin for SWC","archived":false,"fork":false,"pushed_at":"2025-01-21T15:23:18.000Z","size":530,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-12T14:13:06.873Z","etag":null,"topics":["graphql","swc-plugin"],"latest_commit_sha":null,"homepage":"https://npm.im/swc-plugin-minify-graphql","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hikiko4ern.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-15T14:12:59.000Z","updated_at":"2025-01-21T15:22:56.000Z","dependencies_parsed_at":"2024-10-23T02:46:57.051Z","dependency_job_id":null,"html_url":"https://github.com/hikiko4ern/swc-plugin-minify-graphql","commit_stats":null,"previous_names":["hikiko4ern/swc-plugin-minify-graphql"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hikiko4ern%2Fswc-plugin-minify-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hikiko4ern%2Fswc-plugin-minify-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hikiko4ern%2Fswc-plugin-minify-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hikiko4ern%2Fswc-plugin-minify-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hikiko4ern","download_url":"https://codeload.github.com/hikiko4ern/swc-plugin-minify-graphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253754220,"owners_count":21958842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","swc-plugin"],"created_at":"2024-11-02T12:07:35.909Z","updated_at":"2026-02-09T17:36:33.623Z","avatar_url":"https://github.com/hikiko4ern.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swc-plugin-minify-graphql\n\n[GraphQL] query and schema minimizer plugin for [SWC]\n\n## Compatibility\n\nSince WASM plugins are not backward compatible (see [swc-project/swc#5060][swc-wasm-compat-issue], [Selecting the version - SWC][selecting-swc-core]), use the table below to select the correct plugin version:\n\n| plugin version | used `swc_core` version | potentially compatible `swc_core` versions |\n| -------------: | ----------------------: | :----------------------------------------- |\n|          `0.2` |                `10.6.1` | `\u003e=10`                                     |\n|          `0.1` |                 `1.0.2` | `\u003e=0.98.0 \u003c10`                             |\n\n## Usage\n\nInstall the package:\n\n```sh\nnpm i swc-plugin-minify-graphql\n```\n\nand add it to your SWC config.\n\n### Basic\n\nThe plugin handles string literals and template literals marked with the GraphQL comment\n\n```ts\nconst QUERY = /* GraphQL */ `\n\tquery ($id: ID!) {\n\t\timage (id: $id) {\n\t\t\t...img\n\t\t}\n\t}\n\n\tfragment img on Image {\n\t\tid\n\t\turl\n\t}\n`;\n```\n\nminifying them:\n\n```ts\nconst QUERY = /* GraphQL */ `query($id:ID!){image(id:$id){...img}}fragment img on Image{id url}`;\n```\n\nMinification is supported not only for entire queries and schemas, but also for their individual parts (e.g., fragments):\n\n```ts\nconst IMAGE_FIELDS = /* GraphQL */ `\n\tid\n\turl\n`;\nconst IMAGE_FRAGMENT = /* GraphQL */ `\n\tfragment image on Image {\n\t\tid\n\t\turl\n\t}\n`;\n\n// becomes\n\nconst IMAGE_FIELDS = /* GraphQL */ `id url`;\nconst IMAGE_FRAGMENT = /* GraphQL */ `fragment image on Image{id url}`;\n```\n\nGraphQL comments are case-insensitive and can have any number of whitespace characters and asterisks at the beginning and end. `/* graphql */`, `/* GraphQL */`, `/** GraphQL */` and even `/* *** * gRaPhQl * *** */` will work.\n\n### Template literals with expressions\n\nExpressions within template literals are also supported:\n\n```ts\nconst IMAGE = /* GraphQL */ `\n\tid\n\turl\n`;\n\nconst ENTITY = /* GraphQL */ `\n\tid\n\timage {\n\t\t${IMAGE}\n\t\tpreviewUrl\n\t}\n`;\n\n// becomes\n\nconst IMAGE = /* GraphQL */ `id url`;\n\nconst ENTITY = /* GraphQL */ `id image{${IMAGE} previewUrl}`;\n```\n\nBut with a single exception: expressions cannot break GraphQL tokens. The following code is invalid:\n\n```ts\nconst LONG = 'Long';\n\nconst FIELD = /* GraphQL */ `\n\tid\n\tsome${LONG}FieldName\n`;\n\n// becomes\n\nconst FIELD = /* GraphQL */ `id some ${LONG} FieldName`;\n\n// instead of\n\nconst FIELD = /* GraphQL */ `id some${LONG}FieldName`;\n```\n\nWhile the minified code may be correct in some cases, this usage is not intended and can be broken at any time.\n\n### `gql` tag support \u003c!-- spell-checker: ignore gql --\u003e\n\n`gql`/`graphql` tagged template literals are not currently supported, and there are no plans to add support. You can use other plugins like [`graphql-tag-swc-plugin`] that support minification.\n\n## Credits\n\n- [`graphql-minify`](https://github.com/dan-lee/graphql-minify-rs): a re-implementation of [`stripIgnoredCharacters`](https://graphql-js.org/api/function/stripignoredcharacters/) from the [GraphQL.js reference implementation](https://github.com/graphql/graphql-js) in Rust\n\n## License\n\nLicensed under either of\n\n- The Unlicense\n  ([UNLICENSE](./UNLICENSE) or https://unlicense.org/UNLICENSE)\n- MIT license\n  ([LICENSE-MIT](./LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n\u003c!-- links --\u003e\n\n[GraphQL]: https://graphql.org\n[SWC]: https://swc.rs\n[swc-wasm-compat-issue]: https://github.com/swc-project/swc/issues/5060\n[selecting-swc-core]: https://swc.rs/docs/plugin/selecting-swc-core\n[`graphql-tag-swc-plugin`]: https://github.com/rishabh3112/graphql-tag-swc-plugin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhikiko4ern%2Fswc-plugin-minify-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhikiko4ern%2Fswc-plugin-minify-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhikiko4ern%2Fswc-plugin-minify-graphql/lists"}