Hey, guys, <@U02HHM5UW9Z> <@U3D8LQ8HK> do you know...
# orm-help
g
Hey, guys, @Sabin Adams @nikolasburk do you know if there is a way to access some Prisma-generated types of my schema, such as for the
include
or
select
? I'm asking that because I'm wrapping my Prisma functions inside service functions for a Node.js project. Those functions accept
include
or
select
as arguments and I'd like to keep type-safety, but I'm not sure if it is actually possible or the best way to do it. Any advice or suggestions from what you've seen? Here's an example:
Copy code
export interface FindQuizzesByStatusInput {
  status: Status;
  take: number;
  after?: string | null;
  include?: { [key: string]: any }; // not great for type-safety!!!
}

export const findQuizzesByStatus = async (
  input: FindQuizzesByStatusInput
): Promise<Quiz[]> => {
  // ...
}
Thanks!
1
j
Copy code
async findManyForPagination(
    input?: Prisma.AddressFindManyArgs
  ): Promise<PrismaTypes.Address[]> {
    const { select, include, cursor, where, take, skip } = input || {}

    return this.db.address.findMany({
      where: {
        ...where,
        shopId: this.context.shopId,
        ...createOrganisationFilter(this.context),
      },
      take,
      skip,
      ...(cursor && { cursor }),
      ...(!select && include && { include }),
    })
  }
Do you mean like this? to access select, include from each data model?
g
Yes, that's what I am looking for. But, somehow I do not have access to those types. They do not seem to be exported. Is there anything I should do to access those generated types?
You exported them from your generated prisma client?
j
Correct