How do I add a typed property to an input type?
Using the following code, I get the following error:
Error:
{
errorMessage: "Error while loading api",
errorType: "Error",
stackTrace: [
"Error: Cannot determine GraphQL input type for name",
...
]
}
Code:
import { Field, ObjectType, InputType, Int } from 'type-graphql';
@ObjectType()
export class Name {
@Field()
given: string;
@Field()
family: string;
}
@ObjectType()
export class PersonResult {
@Field()
id: string;
@Field(type => Name)
name: Name;
@Field()
email_address: string;
}
@InputType()
export class PersonInput implements Partial<PersonResult> {
@Field(type => Name)
name: Name;
@Field()
email_address: string;
}
My bad. I hadn't specified InputType on the Name class.
@ObjectType()
@InputType('NameInput')
export class Name {
@Field() given: string;
@Field() family: string;
}
Same error here, same solution as well.
Add @InputType()
Thanks~
Most helpful comment
My bad. I hadn't specified
InputTypeon theNameclass.