Building Relations between ObjecTypes in Typgraphql and Prisma

Viewed 27

I am trying to create a relation between 2 ObjecTypes in Typgraphql with Apollo. This is my error:

enter image description here

As you can see in my category section I get null. This should be an item, because I already see it in my prisma ORM

  @FieldResolver(() => Category)
    async categories(@Root() parent: Product, @Ctx() ctx:Context): Promise<Category[]> {
        return await ctx.prisma.category.findUnique({
            where: {id: parent.id}
        }).categories()!  
    }

I created a FieldResolver that returns the category when running the product's id. However, when I run categories at the end I get the following error: Property 'categories' does not exist on type 'Prisma__CategoryClient<Category | null>'.

I don't why I am getting this issue. Any information would be greatly appreciated.

0 Answers
Related