What is the optimal way to get "deep" meta data?


#1

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 looks for shelf ID. Is there a way to call BooksConnection for the current Shelf only?

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
            }
        })
    }
})