TypeScript
validation-schema

TypeScript Validation Schema

Package nameWeekly DownloadsVersionLicenseUpdated
graphql-codegen-typescript-validation-schema (opens in a new tab)DownloadsVersionLicenseJun 10th, 2023

Installation

pnpm add -D graphql-codegen-typescript-validation-schema

Built and maintained by Code-Hex (opens in a new tab)

A plugin for GraphQL Codegen to generate form validation schema (such as yup (opens in a new tab), zod (opens in a new tab)) based on your GraphQL schema for use in a client application.

Examples

Set up your project per the GraphQL Codegen Docs, and specify this plugin in your codegen.yml:

codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli'
 
const config: CodegenConfig = {
  generates: {
    'path/to/graphql.ts': {
      plugins: ['typescript', 'typescript-validation-schema'],
      config: {
        strictScalars: true,
        schema: 'yup'
      }
    }
  }
}
export default config

Usage & Documentation

For the complete documentation, please refer to Code-Hex/graphql-codegen-typescript-validation-schema (opens in a new tab) repository.