Ошибка "CannotDetermineGraphQLTypeError: Cannot determine GraphQL input type for ..."

Есть Mutation в Resolver:

@InputType()
class TurnInput {
  @Field(() => [Letter])
  word: [Letter]; // также пробовал Letter[] и просто [{}]

  @Field(() => Int)
  gameId: number

  @Field(() => Boolean)
  confirmed: boolean
}

@Mutation(() => Game)
async makeTurn(
  @Arg("input") input: TurnInput,
  @Ctx() { req }: MyContext
) { ... }

При запуске выводит ошибку:

CannotDetermineGraphQLTypeError: Cannot determine GraphQL input type for 'word' of 'TurnInput' class. Is the value, that is used as its TS type or explicit type, decorated with a proper decorator or is it a proper input value?

Есть ли какой-то способ передать в аргумент массив объектов своего типа? То есть там будет следующее примерно:

word: [
  {id: 1, char: 's'},
  {id: 2, char:'a'},
  {id: 3, char: 'n'},
  {id: 4, char: 'd'}
]

Ответы (1 шт):

Автор решения: Timofey Melentev

Как оказалось, в type-graphql в декораторе @Arg() можно использовать либо базовые типы, либо те, которые являются @InputType. В моём случае пришлось создавать отдельный @InputType, в котором содержатся необходимые поля:

@InputType()
export class CellInput implements Partial<Letter> {
  @Field(() => Int)
  boxNumber: number;

  @Field(() => String)
  char: string;

  @Field(() => Boolean)
  filled: boolean;

  @Field()
  @Column()
  isNew: boolean;
}
→ Ссылка