[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
When using IntersectionType together with other type mapping utility functions the generated class will provide wrong properties.
Hava a look at the code example. There you will see three Classes Foobar, FoobarCreate and FoobarUpdate. At the buttom you will find a class Test and a constructor where a variable of type FoobarUpdate gets initialised. I have commented the wrong class properties there.
import { ObjectType, Field, ID, InputType, PartialType, OmitType, IntersectionType, PickType } from '@nestjs/graphql';
@ObjectType()
export class Foobar {
@Field(() => ID)
id: string;
@Field(() => String)
name: string;
@Field(() => String)
required: string;
@Field(() => String, {nullable: true})
optional?: string;
}
@InputType() // { required: string, optional?: string }
export class FoobarCreate extends OmitType(Foobar, ['id', 'name'], InputType) {}
@InputType() // { id: string, required?: string, optional?: string }
export class FoobarUpdate extends IntersectionType(PartialType(FoobarCreate), PickType(Foobar, ['id'], InputType)) {}
class Test {
constructor() {
const foobarUpdate: FoobarUpdate = {
id: 'some-id', // works as expected
name: 'some-name', // should not be part of FoobarUpdate class (but is a required property)
required: 'some-required-value', // should be optional property (but is a required property)
optional: "some-value" // works as expected
}
}
}
Nest version: 7.1.4
Node version: v12.16.2
https://docs.nestjs.com/graphql/mapped-types#composition

This part:
['email'] as const
is very important.
Please, test your code with as const added (to both OmitType and PickType calls).
Most helpful comment
https://docs.nestjs.com/graphql/mapped-types#composition
This part:
is very important.
Please, test your code with
as constadded (to bothOmitTypeandPickTypecalls).