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 ?