Rintsi
04/29/2021, 8:02 AM@ResolveField()
async items(@Parent() asset: Asset, @Args('first') first: number) {
return this.prisma.asset.findUnique({ where: { id: asset.id } }).items({ take: first });
}
Rintsi
04/29/2021, 8:07 AMmodel Asset {
id Int @id
...
items Item[]
}
Rintsi
04/29/2021, 8:07 AMRintsi
04/29/2021, 8:08 AMtype Asset {
id: Int!
items(first: Int): [Event!]!
}
So is the ! the magic here. Will it work if I remove those?Rintsi
04/29/2021, 8:09 AMRintsi
04/29/2021, 8:09 AMOdysseas Ragnarson
04/29/2021, 12:56 PM[Event!]
means that list itself is nullable where as the elements are not, if you wanted to have both the list and elements non null it would be [Event!]!
. As for the prisma schema, i encountered the same thing but have deduced that the arrays are nullable by default, meaning that in your case if items are null it will just return null.Odysseas Ragnarson
04/29/2021, 12:57 PM{nullable: 'items' | 'itemsAndList' | true