Michael
06/01/2021, 1:21 PMprisma generate
I'm able to generate models / resolvers using npx prisma generate and all is working as expected. I've created a custom resolver and added it to the resolvers array in buildSchema:
@Resolver((of) => Auction)
export default class AuctionResolver {
@FieldResolver((returns) => Number, { nullable: true })
async totalBids(
@Root() auction: Auction,
@Ctx() { prisma }: Context
): Promise<number> {
const totalBids = await prisma.bid.aggregate({
_count: {
id: true,
},
where: {
auctionId: auction.id,
},
});
return totalBids._count.id;
}
}
The field shows up in graphql playground, but it's not in the generated model class; so when using the model types, I'm getting warnings for totalBids
Property 'totalBids' does not exist on type 'Auction'.ts(2339)Michael
06/01/2021, 1:23 PM