svn
svn

Reputation: 37

NestJS GraphQL - I need to create a string array Field

I have this field in a model but doesn't work

@Field(type => [],{ nullable: true })
product: string[];

I don't know what I miss.

Upvotes: 2

Views: 6018

Answers (1)

pzaenger
pzaenger

Reputation: 11973

You need to add the GraphQL type String. Therefore change [] to [String], an array of strings. You might also want to set product optional (with ?) since it is nullable.

@Field(type => [String], { nullable: true })
product?: string[];

Upvotes: 6

Related Questions