1

调查包含一系列问题。是否可以有一个 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
}
4

1 回答 1

1

我最后就是这样解决的

@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
}
于 2020-12-06T12:11:12.860 回答