fields_{namespace}_input not applied to Update InputType
TzviPM opened this issue · 2 comments
TzviPM commented
in my schema.prisma file, I have:
fields_Validator_from = "class-validator"
fields_Validator_input = true
and a User
model with:
/// @HideField()
/// @Validator.IsString()
/// @Validator.MinLength(8)
password String
the generated output applies the decorators for create inputs:
@InputType()
export class UserCreateInput {
@Field(() => String, {nullable:false})
@Validator.IsString()
@Validator.MinLength(8)
password!: string;
}
but it does not work as expected for update inputs:
@InputType()
export class UserUpdateInput {
@Field(() => StringFieldUpdateOperationsInput, {nullable:true})
password?: InstanceType<typeof StringFieldUpdateOperationsInput>;
}
@InputType()
export class StringFieldUpdateOperationsInput {
@Field(() => String, {nullable:true})
set?: string;
}
TzviPM commented
I was thinking this could be solved by generating a specialized type for the scalar fields with decorators on them, instead of using a general update string field type from the prisma folder. For example, you could have a UserEmailFieldUpdateInput that itself has the decorators from the email
field applied to its set
field. Thoughts? I’d be happy to create a PR.