I made an example below to illustrate my current s...
# orm-help
j
I made an example below to illustrate my current solution for a resolver I need. I suspect it is not optimal however. On a Shelf I want to know if there is any Book but I go through all books and look for the shelf ID. Is there a way to call BooksConnection for the current Shelf only?
Copy code
const Shelf = prismaObjectType({
    name: 'Shelf',
    definition: t => {
        t.prismaFields(['*'])
        t.field('hasBooks', {
            type: 'Boolean',
            resolve: async (root, args, ctx) => {
                return await ctx.prisma.booksConnection({ where: { shelf: { id: root.id }}})
	            	.aggregate()
	            	.count() > 0
            }
        })
    }
})