{"id":41165,"library":"gqlmin","title":"gqlmin","description":"gqlmin is a lightweight (<1 kB, ~3.4 kB gzip with dependency) GraphQL query minifier that removes insignificant whitespace and comments from GraphQL queries. Version 0.3.2 is current, stable, and maintained. It offers both a runtime ESM API and a CLI for build-time use. Unlike alternatives that bundle validation, gqlmin prioritizes minimal size and performance, assuming queries are pre-validated. It's ideal for reducing payload size in large GraphQL apps or optimizing GET requests for caching.","status":"active","version":"0.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/drwpow/gqlmin","tags":["javascript","graphql","gql","query","minify","esm","es","modules","typescript"],"install":[{"cmd":"npm install gqlmin","lang":"bash","label":"npm"},{"cmd":"yarn add gqlmin","lang":"bash","label":"yarn"},{"cmd":"pnpm add gqlmin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Tokenizer dependency for parsing GraphQL queries","package":"moo","optional":false}],"imports":[{"note":"ESM-only; CJS require will fail. Use dynamic import() in CommonJS environments.","wrong":"const gqlmin = require('gqlmin')","symbol":"default","correct":"import gqlmin from 'gqlmin'"},{"note":"There is no named export; only a default export. Do not destructure.","wrong":"const gqlmin = require('gqlmin').default","symbol":"gqlmin","correct":"import gqlmin from 'gqlmin'"},{"note":"TypeScript types are bundled; no separate @types/ package needed.","wrong":null,"symbol":"Type declarations","correct":"import gqlmin from 'gqlmin'"}],"quickstart":{"code":"import gqlmin from 'gqlmin';\n\nconst query = `\n  query allProducts {\n    products {\n      name\n      price\n      image {\n        medium\n        large\n      }\n    }\n  }\n`;\n\nconst minified = gqlmin(query);\nconsole.log(minified);\n// query allProducts{products{name price image{medium large}}}","lang":"typescript","description":"Minifies a GraphQL query by stripping whitespace and comments, using the default import from gqlmin."},"warnings":[{"fix":"Use dynamic import(): const gqlmin = await import('gqlmin');","message":"gqlmin is ESM-only and cannot be required via CommonJS require().","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Validate queries with a GraphQL validator before minifying.","message":"gqlmin does not validate GraphQL; malformed queries may produce incorrect output silently.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure comments are not needed after minification.","message":"Minifies even if query is a fragment or contains comments; comments are removed, not preserved.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider if the size overhead is acceptable for your use case.","message":"The library bundles Moo tokenizer as a dependency, adding ~3.4 kB gzip; tree-shaking may not remove it.","severity":"gotcha","affected_versions":"all"},{"fix":"Use forward slashes or escape paths appropriately.","message":"CLI usage via npx may have different behavior on Windows due to path handling.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.3.2':26 '1':6 '3.4':8 'altern':48 'api':38 'app':74 'assum':58 'build':44 'build-tim':43 'bundl':50 'cach':80 'cli':41 'comment':21 'current':28 'depend':12 'es':87 'esm':37,86 'get':77 'gql':83 'gqlmin':1,2,52 'graphql':13,23,73,82 'gzip':10 'ideal':66 'insignific':18 'javascript':81 'kb':7,9 'larg':72 'lightweight':5 'maintain':31 'minifi':15,85 'minim':54 'modul':88 'offer':33 'optim':76 'payload':69 'perform':57 'pre':62 'pre-valid':61 'priorit':53 'queri':14,24,59,84 'reduc':68 'remov':17 'request':78 'runtim':36 'size':55,70 'stabl':29 'time':45 'typescript':89 'unlik':47 'use':46 'valid':51,63 'version':25 'whitespac':19","created_at":"2026-06-04T18:51:05.470635+00:00","updated_at":"2026-06-04T18:51:05.470635+00:00","problems":[{"fix":"Use dynamic import: const gqlmin = await import('gqlmin');","cause":"Trying to require() the ESM-only package in a CommonJS environment.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/gqlmin/index.js from /path/to/app.js not supported."},{"fix":"Use: import gqlmin from 'gqlmin';","cause":"Using a named import (e.g., import { gqlmin } from 'gqlmin') instead of default import.","error":"Uncaught TypeError: gqlmin is not a function"},{"fix":"Pre-validate the GraphQL query with a parser like graphql's parse() before minifying.","cause":"Input GraphQL query is malformed; gqlmin does not validate and produces incorrect output.","error":"SyntaxError: Unexpected identifier at position X in the minified output."},{"fix":"Run: npm install gqlmin (will install moo as a dependency).","cause":"Moo dependency missing, possibly due to flat node_modules or incorrect install.","error":"Cannot find module 'moo' or 'moo' not found."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/drwpow/gqlmin#readme","github":"https://github.com/drwpow/gqlmin","docs":null,"changelog":null,"pypi":null,"npm":"gqlmin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}