UNPKG

graphql-codegen-typescript-validation-schema

Version:

GraphQL Code Generator plugin to generate form validation schema from your GraphQL schema

17 lines (16 loc) 821 B
import type { TypeNode } from 'graphql'; import type { Visitor } from './visitor.js'; /** * Wraps a schema expression in a library-specific lazy reference when the type * is a complex (non-scalar, non-enum) named type, avoiding issues with * mutually-recursive input types. * * Each validation library has its own lazy syntax (z.lazy, v.lazy, etc.), so * callers supply the wrapper function. * * @param visitor - Type lookup used to distinguish scalars/enums from complex types. * @param type - GraphQL type node for the schema expression. * @param schema - Generated schema expression to wrap when needed. * @param lazyWrapper - e.g. `(s) => \`z.lazy(() => ${s})\`` */ export declare function buildMaybeLazy(visitor: Visitor, type: TypeNode, schema: string, lazyWrapper: (schema: string) => string): string;