Prisma 1 Forum

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

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.field('hasBooks', {
            type: 'Boolean',
            resolve: async (root, args, ctx) => {
                return await ctx.prisma.booksConnection({ where: { shelf: { id: }}})
	            	.count() > 0

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.