NestJS GraphQL - 我需要创建一个字符串数组字段

svn*_*svn 1 graphql nestjs

我的模型中有这个字段,但不起作用

@Field(type => [],{ nullable: true })
product: string[];
Run Code Online (Sandbox Code Playgroud)

我不知道我想念什么。

pza*_*ger 5

您需要添加 GraphQL 类型String。因此更改[][String],一个字符串数组。您可能还想设置product可选(with ?),因为它是nullable

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