{"_id":"@cubicecho/graphql-codegen-field-descriptions","name":"@cubicecho/graphql-codegen-field-descriptions","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@cubicecho/graphql-codegen-field-descriptions","version":"1.0.0","description":"GraphQL Code Generator plugin that emits your SDL field descriptions as a runtime map, so authored docs are available at run time and not just as JSDoc.","keywords":["graphql","graphql-codegen","graphql-code-generator","codegen","descriptions","documentation","plugin","typescript"],"license":"MIT","author":{"name":"Benjamin Van Treese"},"type":"module","engines":{"node":">=20"},"repository":{"type":"git","url":"git+https://github.com/cubicecho/graphql-codegen-field-descriptions.git"},"homepage":"https://github.com/cubicecho/graphql-codegen-field-descriptions#readme","bugs":{"url":"https://github.com/cubicecho/graphql-codegen-field-descriptions/issues"},"main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/esm/index.d.ts","exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.js"}},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"scripts":{"clean":"node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"","build":"npm run clean && tsc -p tsconfig.build.json && tsc -p tsconfig.cjs.json && node scripts/postbuild.mjs","prepack":"npm run build","typecheck":"tsc --noEmit","typecheck:tests":"tsc -p tsconfig.tests.json","test":"vitest run","test:watch":"vitest","coverage":"vitest run --coverage","format":"biome format --write .","lint":"biome lint .","check":"biome check ."},"peerDependencies":{"@graphql-codegen/plugin-helpers":">=5","graphql":">=16 <18"},"devDependencies":{"@biomejs/biome":"^2.5.0","@graphql-codegen/plugin-helpers":"^5.1.1","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.8","@semantic-release/npm":"^13.1.5","@semantic-release/release-notes-generator":"^14.1.1","@types/node":"^24.0.0","@vitest/coverage-v8":"^3.2.6","graphql":"^16.14.0","semantic-release":"^25.0.5","typescript":"^5.7.0","vitest":"^3.1.3"},"gitHead":"700a859fd8ee2672875fce46ab114fea4af68cce","_id":"@cubicecho/graphql-codegen-field-descriptions@1.0.0","_nodeVersion":"26.4.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-cqtGo6IcASVPP3fwQ4gIXmCw4t1MmdB7/JuOQ0yydSBj7B7ZOOPKIPXVzqwKFj8RXtXnuXtaoeoyV3tUEzeBWQ==","shasum":"70023be806f63efcd090c2f75d5ce1e77274d3a1","tarball":"https://registry.npmjs.org/@cubicecho/graphql-codegen-field-descriptions/-/graphql-codegen-field-descriptions-1.0.0.tgz","fileCount":13,"unpackedSize":25868,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD4ie2WXQ/y1Y/X490fs9ZEohfbrExcq4wXeCP2xzzNbAIgcCmaNL6eyBD8ZEfKSVuWdqIqFZjPbxmsN8HooIvNRQU="}]},"_npmUser":{"name":"vantreeseba","email":"vantreeseba@gmail.com"},"directories":{},"maintainers":[{"name":"vantreeseba","email":"vantreeseba@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/graphql-codegen-field-descriptions_1.0.0_1787928534468_0.28493824947266133"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-28T14:48:54.329Z","1.0.0":"2026-08-28T14:48:54.594Z","modified":"2026-08-28T14:48:54.790Z"},"maintainers":[{"name":"vantreeseba","email":"vantreeseba@gmail.com"}],"description":"GraphQL Code Generator plugin that emits your SDL field descriptions as a runtime map, so authored docs are available at run time and not just as JSDoc.","homepage":"https://github.com/cubicecho/graphql-codegen-field-descriptions#readme","keywords":["graphql","graphql-codegen","graphql-code-generator","codegen","descriptions","documentation","plugin","typescript"],"repository":{"type":"git","url":"git+https://github.com/cubicecho/graphql-codegen-field-descriptions.git"},"author":{"name":"Benjamin Van Treese"},"bugs":{"url":"https://github.com/cubicecho/graphql-codegen-field-descriptions/issues"},"license":"MIT","readme":"# @cubicecho/graphql-codegen-field-descriptions\n\nA [GraphQL Code Generator](https://the-guild.dev/graphql/codegen) plugin that emits your\nSDL field descriptions as a **runtime** map.\n\nSDL `\"\"\"...\"\"\"` descriptions are normally compile-time only — codegen turns them into JSDoc\non the generated TypeScript types, which disappears at run time. This plugin captures them\nas data instead, so the app can render authored field documentation (an info tooltip beside\na form label, help text in an admin UI, an LLM tool description, …).\n\n## Install\n\n```sh\nnpm install --save-dev @cubicecho/graphql-codegen-field-descriptions\n```\n\n`graphql` and `@graphql-codegen/plugin-helpers` are peer dependencies.\n\n## Usage\n\n```ts\n// codegen.ts\nimport type { CodegenConfig } from '@graphql-codegen/cli';\n\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  generates: {\n    './src/__generated__/descriptions.ts': {\n      plugins: ['@cubicecho/graphql-codegen-field-descriptions'],\n    },\n  },\n};\n\nexport default config;\n```\n\nGiven:\n\n```graphql\ntype InventoryItem {\n  \"\"\"\n  Quantity at which a restock is triggered.\n  \"\"\"\n  reorderLevel: Int!\n  quantity: Int!\n}\n```\n\nit generates:\n\n```ts\n// This file is auto-generated by @cubicecho/graphql-codegen-field-descriptions — do not edit.\nexport const FieldDescriptions = {\n  \"InventoryItem\": {\n    \"reorderLevel\": \"Quantity at which a restock is triggered.\",\n  },\n} as const;\n\nexport type FieldDescriptionMap = typeof FieldDescriptions;\n```\n\nFields without a description are skipped, and so is any type left with no described fields —\nthat keeps the generated file to roughly the size of the documentation you actually wrote.\n\nReading it back:\n\n```ts\nimport { FieldDescriptions } from './__generated__/descriptions.js';\n\nexport function getFieldDescription(typeName: string, fieldName: string): string | undefined {\n  const fields = (FieldDescriptions as Record<string, Record<string, string>>)[typeName];\n  return fields?.[fieldName];\n}\n```\n\n## Config\n\n| Option                | Type               | Default                | Description                                                        |\n| --------------------- | ------------------ | ---------------------- | ------------------------------------------------------------------ |\n| `exportName`          | `string`           | `'FieldDescriptions'`  | Name of the emitted const.                                          |\n| `typeName`            | `string \\| false`  | `'FieldDescriptionMap'`| Name of the emitted `typeof` alias; `false` skips it.               |\n| `includeInterfaces`   | `boolean`          | `true`                 | Include interface types.                                            |\n| `includeInputObjects` | `boolean`          | `false`                | Include input object types.                                         |\n| `asConst`             | `boolean`          | `true`                 | Emit `as const`, narrowing each description to a string literal.    |\n\n```ts\n'./src/__generated__/descriptions.ts': {\n  plugins: ['@cubicecho/graphql-codegen-field-descriptions'],\n  config: {\n    exportName: 'Docs',\n    includeInputObjects: true,\n  },\n},\n```\n\n`exportName` and `typeName` are interpolated into the output, so the plugin rejects anything\nthat is not a valid TypeScript identifier before codegen writes a broken file.\n\n## Development\n\n```sh\nnpm test          # vitest\nnpm run coverage  # vitest + v8 coverage thresholds\nnpm run build     # ESM (dist/esm) + CJS (dist/cjs) via tsc\nnpm run check     # biome\n```\n\nReleases are automated: Conventional Commits on `main` drive semantic-release, which\npublishes to npm and cuts the GitHub release.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-9f49bddc3758346db0969de039b28f95"}