GraphQL Code Generator plugin that generates form validation schemas (yup, zod, myzod, valibot) from your GraphQL schema. Current stable version 0.19.0. Releases are frequent; supports multiple validator libraries including zod v4. Key differentiator: automates creating consistent validation logic from GraphQL type definitions, reducing duplication between schema and client validation. Supports scalars, custom schemas, and strict mode. Requires graphql and a validator peer dependency.
npm install graphql-codegen-typescript-validation-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures graphql-codegen to generate Zod v4 validation schemas from a GraphQL schema file, including scalar mappings and strict mode.
Switch to codegen.ts with CodegenConfig type import.
Ensure scalars.ID is mapped to { input: 'string', output: 'string' } in codegen config.Write scalar schema as a string that will be output in generated code, e.g., 'z.string().datetime()'.
Install the appropriate validator package and set the 'schema' field to the correct key: 'yup', 'zod', 'zodv4', 'myzod', or 'valibot'.
Order plugins: ['typescript', { 'typescript-validation-schema': ... }].Ensure graphql version satisfies ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0.
Move options like 'scalarSchemas' into the plugin config object.
Run: npm install zod
Run: npm install -D graphql-codegen-typescript-validation-schema
Wrap the value in quotes: 'z.string().datetime()' instead of z.string().datetime()
Set 'schema' to a valid value: 'zodv4' for Zod v4.