Describe the Bug
While trying to pass an input with a nested array field, the object comes up empty on the resolver
To Reproduce
@ObjectType()
@InputType('InnerInput')
export class Inner {
@Field((type) => String)
aString: string
@Field((type) => Int)
aNumber: number
}
@InputType()
export class Outer {
@Field((type) => [[Inner]])
nested: Inner[][]
}
md5-51b8bceea54167a15a848aa646ac3e53
@Resolver()
export class TestResolver {
@Query((type) => Inner)
test(@Arg('input', (type) => Outer) input: Outer) {
return input[0][0].nested
}
}
md5-aa2ce18a929323f4ba221075d257cdb2
{
test(input: {nested: [[{aString: "test", aNumber: 90}]]}) {
aString
aNumber
}
}
Expected Behavior
The query should return the object {aString: "test", aNumber: 90}. Instead, it returns the error "Cannot read property '0' of undefined"
Environment (please complete the following information):
@pablojmp Sorry but unable to reproduce:
https://github.com/MichalLytek/type-graphql/blob/v1.1.1/tests/functional/resolvers.ts#L1414-L1420
https://github.com/MichalLytek/type-graphql/blob/v1.1.1/tests/functional/resolvers.ts#L1767-L1787
Please create a PR with a failing test case 馃槈
Yes, I know the nested array on Arg passed, but this is not the same:
@Arg('input', (type) => Outer)
this is a nested array inside the InputType decorated class
vs
@Arg("inputs", type => [[[SampleInput]]])
here the input is a nested array
I'll create a test case shortly
Thanks 馃槈
Fixed by f9499e2 馃敀
thanks for the quick fix @MichalLytek!