21 lines
463 B
TypeScript
21 lines
463 B
TypeScript
import { Field, ObjectType, Int, ID } from '@nestjs/graphql';
|
|
import { Type } from '@nestjs/common';
|
|
|
|
export function Paginated<T>(classRef: Type<T>): 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;
|
|
}
|