Cannot use Input type from nexus schema when calling prisma client from custom resolver

prisma

#1

Hi,

I was following the prisma nexus section of nexus docs for creating a custom resolver. The below code is suggested by the docs.

    const Query = prismaObjectType({
      name: 'Query',
      definition(t) {
        t.field('users', {
          ...t.prismaType.users,
          resolve(root, args, ctx) {
            // Custom implementation
          },
        })
      },
    })

But when I use the arguments to pass it to prisma client mutation, it is giving type errors. The errors are mostly related to id attribute. Please find the code and error below,

const Mutation = prismaObjectType({
  name: "Mutation",
  definition: t => {
t.prismaFields(["*"]);
t.field('createProduct',{
  ...t.prismaType.createProduct,
  resolve(root,args,context:{prisma:Prisma}){
    return context.prisma.createProduct(args.data);
  }
})
  }
});

Type error:

Types of property ‘connect’ are incompatible.
Type ‘{ id?: string | null | undefined; } | null | undefined’ is not assignable to type ‘Maybe<AtLeastOne<{ id: Maybe<ID_Input>; }, { id: Pick<{ id: Maybe<ID_Input>; }, “id”>; }>>’.
Type ‘{ id?: string | null | undefined; }’ is not assignable to type ‘AtLeastOne<{ id: Maybe<ID_Input>; }, { id: Pick<{ id: Maybe<ID_Input>; }, “id”>; }>’.
Type ‘{ id?: string | null | undefined; }’ is not assignable to type ‘Pick<{ id: Maybe<ID_Input>; }, “id”>’.
Property ‘id’ is optional in type ‘{ id?: string | null | undefined; }’ but required in type ‘Pick<{ id: Maybe<ID_Input>; }, “id”>’.ts(2345)

Is there anything else we need to do to make it work ?? any help will be much appreciated.