Sascha
03/22/2021, 1:57 PMSascha
03/22/2021, 1:57 PMt.int("assignments_count", {
resolve(root, _args, ctx) {
return ctx.prisma.assignment.count({
where: {
formPrototypeId: root.id,
},
});
},
});
Sascha
03/22/2021, 1:58 PMRyan
03/22/2021, 2:07 PMRyan
03/22/2021, 2:09 PMRyan
03/22/2021, 2:10 PMconst User = ns.objectType({
name: 'User',
definition(t) {
<http://t.nonNull.int|t.nonNull.int>('id')
t.nonNull.string('name')
t.field('total', {
type: 'Int',
resolve(_parent, _args, ctx) {
console.log('called')
return ctx.prisma.user.count()
},
})
},
})
const Query = ns.queryField((t) => {
t.list.field('users', {
type: 'User',
resolve(_root, _args, ctx) {
return ctx.prisma.user.findMany()
},
})
})
I have added a log in the custom field and it only logs when the field is explicitly stated in the PlaygroundSascha
03/22/2021, 2:41 PM1.0.0
Sascha
03/22/2021, 2:42 PMRyan
03/25/2021, 7:37 AMSascha
04/19/2021, 10:14 AM