0

I have a NestJS (core version 8.2.4) GraphQL input type. I am getting an error when trying to use a custom input type in a array field (doesn't happen if I change the custom input type to Object)

Caught exception: Error: Cannot determine a GraphQL output type
for the "arrayValue". Make sure your class is decorated with an
appropriate decorator. CannotDetermineOutputTypeError:
Cannot determine a GraphQL output type for the "arrayValue".
Make sure your class is decorated with an appropriate decorator.

Here is the relevant code:

@InputType()
export class ChildInputType {
    @Field()
    readonly val1: number;

    @Field()
    readonly val2: number;
}

@InputType()
export class ParentInputType {

    @Field({ nullable: true })
    readonly name: string;

    @Field(type => [ChildInputType], { nullable: true }) // changing to [Object] works
    readonly arrayValue?: ChildInputType[];

}

Any idea how I get this to work? It's basically the same code as in NestJS GraphQL Resolvers docs example of Author and its [Post] field but it still doesn't work.

Sagi Mann
  • 2,967
  • 6
  • 39
  • 72

0 Answers0