How can I use Prisma types on a nest.js GraphQL query argument

How can I use Prisma types on a nest.js GraphQL query argument


0

I’m working on a simple GraphQL query that allows me to fetch a list of users. I want to be able to sort them through my request. I’m using Prisma as an ORM.

As per the documentation, my service simply looks like this:

  /**
   * Find all users
   */
  findAll({
    skip,
    take,
    cursor,
    where,
    orderBy,
  }: {
    skip?: number;
    take?: number;
    cursor?: Prisma.UserWhereUniqueInput;
    where?: Prisma.UserWhereInput;
    orderBy?: Prisma.UserOrderByWithRelationInput;
  }) {
    return this.prisma.user.findMany({
      skip,
      take,
      cursor,
      where,
      orderBy,
    });
  }

Now, I’d like to add the arg to my query, so I went with this:


    @Args("orderBy", {
      defaultValue: { createdAt: "desc" },
      type: () => Prisma.UserOrderByWithRelationInput,
      nullable: true,
    })

But this raises an error, saying that Property 'UserOrderByWithRelationInput' does not exist on type 'typeof Prisma'.

How can I specify the type of this arg, using the generated Prisma types ?


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *