graphql-codegen-typescript-validation-schema
Version:
GraphQL Code Generator plugin to generate form validation schema from your GraphQL schema
19 lines (18 loc) • 900 B
TypeScript
import type { ValidationSchemaPluginConfig } from './config.js';
import type { Visitor } from './visitor.js';
/**
* Builds a library-specific scalar schema expression.
*
* All five validation libraries follow the same pattern: check for a custom
* `scalarSchemas` override, fall back to a built-in type map for the resolved
* TypeScript type (string/number/boolean), then apply `defaultScalarTypeSchema`,
* and finally warn and return the library fallback.
*
* The only per-library differences are the strings in `typeMap`, the `fallback`
* value, and whether custom schemas need wrapping (yup appends `.defined()`).
*/
export declare function buildScalarSchema(config: ValidationSchemaPluginConfig, visitor: Visitor, scalarName: string, options: {
typeMap: Record<'string' | 'number' | 'boolean', string>;
fallback: string;
wrapCustom?: (schema: string) => string;
}): string;