Suppose I want to execute a many-to-many mutation like below, which is cited from prisma.io:
const createCategory = await prisma.post.create({
data: {
title: 'How to be Bob',
categories: {
create: [
{
assignedBy: 'Bob',
assignedAt: new Date(),
category: {
create: {
name: 'New category',
},
},
},
],
},
},
})
To implement Graphql resolver, it looks like I have to create a DTO class annotated by @InputType()
and annotate the categories property with @Field
there; however, I have no idea how I can leverage auto-generated Prisma types for it. Otherwise, NestJS complains:
Error: Cannot determine a GraphQL output type for the "categories". Make sure your class is decorated with an appropriate decorator.
I tried to specify something like @Field(() => [Prisma.PostCategoryScalarFieldEnum], { nullable: true })
but I got the following error:
throw new cannot_determine_input_type_error_1.CannotDetermineInputTypeError(hostType, typeRef);
Error: Cannot determine a GraphQL input type null for the "aliases". Make sure your class is decorated with an appropriate decorator.
I’m new to NestJS and Prisma and not so familiar with Graphql either. So let me know if you find anything unclear.