Error: Expected [object Object] to be a possible input type, saw GraphQLObjectType(Category)

277 views Asked by At

I am trying to get trying to create a Product with the following fields, however whenever I try to have my categories object within my Product Object equal an actual Category Object that is already made I get the error above.

I want to have an [Category] be the value of the categories field within my Product Object, I hope that makes sense.

import {Category} from "./Category"

export const ProductMutation = extendType({
    type: "Mutation",
    definition(t) {
        //create a new item
        t.nonNull.field('createProduct', {
            type:'Product',
            args: {
                id: stringArg(),
                name: nonNull(stringArg()),
                description: (stringArg()), 
                ingredients: list(stringArg()),
                img: (stringArg()),
                moveActive: (booleanArg()),
                price: (floatArg()),
                category: list(stringArg()), // this needs to be type Category and then i should be good
                //tried category: list(arg({ type: Category})), (this didn't work)
            },
            resolve(_root, args, ctx) {
                return ctx.prisma.product.create({
                    data: {
                        name: args.name,
                        description: args.description,
                        ingredients: args.ingredients,
                        img: args.img,
                        moveActive: args.moveActive,
                        price: args.price,
                        category: args. category
                    }
                })
            }
        })
    }
})

0

There are 0 answers