Skip to content

Add type-level Zod descriptions#1430

Merged
Code-Hex merged 1 commit intomainfrom
codex/type-level-descriptions
Apr 25, 2026
Merged

Add type-level Zod descriptions#1430
Code-Hex merged 1 commit intomainfrom
codex/type-level-descriptions

Conversation

@Code-Hex
Copy link
Copy Markdown
Owner

What changed

withDescriptions: true already emitted .describe(...) for Zod fields. This adds the same treatment to the generated schema itself when the GraphQL type has a description.

Covered cases:

  • zod and zodv4
  • input object schemas
  • object and interface schemas when withObjectType is enabled
  • function and const export modes
  • @oneOf input objects
  • strict object schemas, so the output becomes .strict().describe(...)

The description text uses JSON.stringify, matching the field-level path and keeping quotes, backslashes, and newlines valid in the generated TypeScript.

Fixes #1429.

Checks

  • pnpm vitest run tests/zod.spec.ts tests/zodv4.spec.ts
  • pnpm test
  • pnpm type-check
  • pnpm lint

@Code-Hex Code-Hex marked this pull request as ready for review April 25, 2026 16:51
@Code-Hex Code-Hex merged commit a106e9f into main Apr 25, 2026
2 checks passed
@Code-Hex Code-Hex deleted the codex/type-level-descriptions branch April 25, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add type-level descriptions to generated Zod schemas

1 participant