Closed
Description
When supplying a falsy argument to a custom directive, the argument is omitted from the generated schema.
Sample GQL: (with codgen config from https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema/blob/main/codegen.yml)
input EventArgumentInput {
name: String! @constraint(minLength: 0)
value: String! @constraint(startsWith: "foo")
}
directive @constraint(
minLength: Int
startsWith: String
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
Expected Schema Output:
export function EventArgumentInputSchema(): yup.SchemaOf<EventArgumentInput> {
return yup.object({
name: yup.string().defined().min(0),
value: yup.string().defined().matches(/^foo/)
})
}
Actual Schema Output:
export function EventArgumentInputSchema(): yup.SchemaOf<EventArgumentInput> {
return yup.object({
name: yup.string().defined().min(), // <-- "Expected 1-2 arguments, but got 0. ts(2554)"
value: yup.string().defined().matches(/^foo/)
})
}
I intend on submitting a PR to resolve this issue.
Metadata
Metadata
Assignees
Labels
No labels