import { Field, ObjectType, Int, ID } from '@nestjs/graphql'; import { Type } from '@nestjs/common'; export function Paginated(classRef: Type): any { @ObjectType({ isAbstract: true }) abstract class PaginatedType { @Field((type) => [classRef]) nodes: T[]; @Field((type) => ID, { nullable: true }) cursor?: number; @Field((type) => Int) totalCount: number; @Field() hasNextPage: boolean; } return PaginatedType; }