Deep Partial InputType for Nestjs GraphQL

Viewed 558

With REST I'm using a DeepPartial from TypeOrm as an input type (DTO) and the ValidationPipe.

Now I'm migrating to GraphQL, which only has PartialType as Mapped Types in Nestjs.

@InputType()
class B {
  @Field()
  n1: string;
  @Field()
  n2: string;
}

@InputType()
class NewA {
  @Field()
  n: string;

  @Field()
  b: B
}


@InputType()
export class UpdateA extends PartialType(NewA) {}  

If I now provide

{ b: { n1: "A" } } 

as input, Nestjs complains about the missing n2 because it's not DeepPartial.

How would I use deep partials with GraphQL?

0 Answers
Related