Closed
Description
Version
v0.3.0
Reproduce
codegen.yml
schema: ./schema.graphql
documents:
- ./app/frontend/javascripts/graphql/**/*.graphql
overwrite: true
generates:
./app/frontend/javascripts/graphql/generated/zodSchema.tsx:
plugins:
- typescript
- typescript-validation-schema
config:
schema: zod
strictScalars: true
directives:
constraint:
minLength: ['min', "$1", "$1文字以上入力してください"]
maxLength: ['max', "$1", "$1文字以内で入力してください"]
scalars:
Date: string
DateTime: string
File: File
ISO8601DateTime: string
scalarSchemas:
File: z.instanceof(File)
schema.graphql
input UserCreateInput {
profile: String @constraint(minLength: 1, maxLength: 5000)
}
zodSchema.tsx
export function UserCreateInputSchema(): z.ZodSchema<UserCreateInput> {
return z.object({
profile: z.string().nullish().min(1, "1文字以上入力してください").max(5000, "5000文字以内で入力してください"),
})
}
Actual Behavior
TS2339: Property 'min' does not exist on type 'ZodNullable >'.
error occur in zodSchema.tsx.
profile: z.string().nullish().min(1, "1文字以上入力してください").max(5000, "5000文字以内で入力してください"),
})
Expected Behavior
zodSchema.tsx
export function UserCreateInputSchema(): z.ZodSchema<UserCreateInput> {
return z.object({
profile: z.string().min(1, "1文字以上入力してください").max(5000, "5000文字以内で入力してください").nullish(),
})
}