I'm trying to create a graphql mutation to edit the account details of my app users. An account have fields for gender and birthday (optional fields). In my InputType I have:
@InputType()
export class UserEditAccountDetailsInput {
@Field()
email: string;
@Field(() => String, { nullable: true })
birthday?: string | null
@Field(() => String, { nullable: true })
gender?: string | null
}
And for the ObjectType:
@Field({ nullable: true })
@Column({ default: null })
gender?: string
@Field({ nullable: true })
@Column({ default: null, type: 'date' })
birthday?: string
I've tried in this way:
@Field({ nullable: true })
@Column({ default: null, type: 'date' })
birthday?: string | null
but I receive this error:
NoExplicitTypeError: Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for 'birthday' of 'User' class.
I've also tried to specify the type for birthday and gender like this:
@Field(() => String, { nullable: true })
@Column({ default: null, type: 'date' })
birthday?: string
but the issue wasn't fixed.
If I don't specify that " | null" on my ObjectType, it seems to work fine, but I have this TypeScript issue:
Types of property 'gender' are incompatible. Type 'string | null | undefined' is not assignable to type '(() => string) | QueryDeepPartialEntity<string | undefined>'.
Do you have any ideas about what I can do?