A GraphQL codegen plugin that generates Zod schemas from GraphQL input types. Version 1.10.6 is stable, actively maintained. It allows developers to define validation rules via GraphQL directives (@validation) or rely on required fields only. Key differentiator: keeps GraphQL as single source of truth for validation, supports custom scalar mappings, and integrates with GraphQL Code Generator ecosystem.
npm install graphql-codegen-zodNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Generates Zod schemas from GraphQL input types using codegen.yml configuration with optional directives for validation.
Use only for input validation. For output schemas, consider other tools.
Set onlyWithValidation: true only if you intend to skip inputs without @validation directives.
Define zodSchemasMap for custom scalars, e.g., EmailAddress: z.string().email()
Include the directive definition in your schema file used as codegen schema.
Add the directive definition from the documentation to your schema file.
Add @validation directive to the input or set onlyWithValidation: false.
Add zodSchemasMap: { EmailAddress: 'z.string().email()' } in codegen.yml plugin config.