NodeJS 是否可以在InputType中定义Object?或者是否可以在InputType中定义InputType?

rt4zxlrg  于 2022-11-29  发布在  Node.js
关注(0)|答案(1)|浏览(176)

调查包含问题数组。是否可以有InputType或Question数组?

@InputType()
export class SurveyInput {
  @Field(() => String)
  name: string
  @Field(() => String)
  status: string
  @Field(() => String)
  category: string
  @Field(() => String)
  initiativeId: string
  @Field(() => QuestionInput)
  questions: QuestionInput[]
}
@InputType()
export class QuestionInput {
  @Field(() => String)
  question: string
  @Field(() => String)
  maxPoint: number
}
5ktev3wc

5ktev3wc1#

"这就是我最后的答案"

@InputType()
export class SurveyInput {

  @Field(() => String)
  name: string
  @Field(() => String)
  status: string
  @Field(() => String)
  category: string
  @Field(() => String)
  initiativeId: string

  @Field(() => [QuestionInput])
  questions: QuestionInput[]
}

@InputType()
export class QuestionInput {

  @Field(() => String)
  question: string

  @Field(() => Number)
  maxPoint: number
}

相关问题