i need create custom pagination result for my graphql types this is my PaginateResult ObjectType
@ObjectType()
export class PaginateResult<T> {
@Field()
docs: T[];
@Field()
totalDocs: string;
@Field()
totalPages: string;
}
and call it in resolvers
@Query((type) => PaginateResult<User>, { nullable: true })
async getUsers(@Args({ type: () => GetAllUserArgs }) args: GetAllUserArgs) {
const queryResolver: QueryResolver = new QueryResolver(args);
return this.userService.getAll(queryResolver.query);
}
and User ObjectType
@ObjectType()
export class User {
@Field(() => ID)
id: string;
@Field()
fullName: string;
@Field()
companyName: string;
@Field()
mobile: string;
@Field({ nullable: true })
profilePhoto?: string;
@Field()
isActive: boolean;
}
but this not work
Error: Undefined type error. Make sure you are providing an explicit type for the "docs" of the "PaginateResult" class.