unlight/prisma-nestjs-graphql

Losing validation on generated update input fields.

corynorris opened this issue · 3 comments

First of, Loving what this package does, it's incredibly helpful thanks for sharing it!

I am having one issue however (I might be doing something incorrectly) but when I setup a validator as follows and generate my input types:

generator nestgraphql {
  provider               = "node node_modules/prisma-nestjs-graphql"
  output                 = "../src/@generated/prisma-nestjs-graphql"
  fields_Validator_from  = "class-validator"
  fields_Validator_input = true
}
//....
model User {
  /// @Validator.IsEmail()
  email String @unique
}

Then my UserCreateInput input is as I would expect, and works great:

    @Field(() => String, {nullable:false})
    @Validator.IsEmail()
    email!: string;

However in the update input, it's converted to a StringFieldUpdateOperationsInput and as a result it loses any validation:

  @Field(() => StringFieldUpdateOperationsInput, { nullable: true })
  email?: StringFieldUpdateOperationsInput;

Is there a way to drop the StringFieldUpdateOperationsInput and keep the validation on the inputs? Or otherwise, is there a different approach to handling updates?

Thanks!

Nvm I guess noAtomicOperations is the flag I'm looking for

I think you should add @ValidateNested(), see #48

Hi @corynorris, i'm having the same issue... I have no idea about how to validade fields at update operations. Same thing using where, at FindMany{entity}Args for example, i would like to have decorators in where property of FindManyArgs Class, like

@Validator.MinLength(2)
name: string;

But we have

name: string;

Missing the validation.

How did you solve this problem?