-
-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
good first issueGood for newcomersGood for newcomers
Description
The plugin isn't applying the constraints from the GraphQL input definition to the generated zod schema. Based on what I can tell from the codebase, everything seems to be configured correctly. Am I missing something here?
Current config definitions:
overwrite: true
generates:
...
./src/graphql/__generated__/partnerApiValidations.ts:
schema: '...'
config:
schema: zod
strictScalars: true
directives:
constraint:
min: min
max: max
pattern: [regex, /$1/, "invalid input"]
startsWith: [regex, /^$1/, "invalid input"]
format:
email: email
uri: url
emoji: emoji
plugins:
- typescript-validation-schema
Directive definition:
directive @constraint(min: Int, max: Int, pattern: String, startsWith: String, format: ConstraintFormat) on INPUT_FIELD_DEFINITION
enum ConstraintFormat {
email
uri
}
Directive used as:
input ProductCreateInput {
title: String! @constraint(min: 5, max: 80)
}
Codegen output:
export function ProductCreateInputSchema(): z.ZodObject<Properties<ProductCreateInput>> {
return z.object({
title: z.string()
})
}
pvlvstepan
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers