Josef Henryson
09/24/2019, 3:04 PMconst 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
}
})
}
})