I'm trying to create an Alert class as follows:
@ObjectType()
export class Alert {
@Field()
status: 'error' | 'success' | 'warning' | 'info' | undefined
@Field(() => [String])
messages: string[];
}
However, it gives me the following error message:
Error: Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for 'status' of 'Alert' class.
Create a type for 'error' | 'success' | 'warning' | 'info' | undefined
and add it to the field definition as such:
@Field(() => StatusType)
It's basically complaining that it can't infer the type of that field as it's not a primitive, whenever a field is an object or other user defined type you will need to provide type information like I've described
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With