{"_id":"@azhulin/pagination-nestjs-graphql","_rev":"3-1ba4bf69f636182a5ba32c948b1e1f68","name":"@azhulin/pagination-nestjs-graphql","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@azhulin/pagination-nestjs-graphql","version":"1.0.0","keywords":["pagination","cursor","cursor-pagination","keyset-pagination","offset-pagination","nestjs","graphql","graphql-connections","relay","relay-connections","code-first","apollo","typescript"],"author":{"name":"Alex Zhulin"},"license":"MIT","_id":"@azhulin/pagination-nestjs-graphql@1.0.0","maintainers":[{"name":"azhulin","email":"zhulin.dem@gmail.com"}],"homepage":"https://github.com/azhulin/pagination#readme","bugs":{"url":"https://github.com/azhulin/pagination/issues"},"dist":{"shasum":"cdec628d2bd0f424dcc88366537ebd9d6b42b1bc","tarball":"https://registry.npmjs.org/@azhulin/pagination-nestjs-graphql/-/pagination-nestjs-graphql-1.0.0.tgz","fileCount":15,"integrity":"sha512-DsRT9O10Vgj4zO0r/X3sgr5qRYcbCHwyH7Ip37ZLFpzTH50SXvrzjIxpX/wYoZBO+LIfykM6C18/p/ydaWYETA==","signatures":[{"sig":"MEUCIQD1m9UUzYXipDP8FPXeUnyfFCrgvQGsX9zocySUvtsLnQIgDZwJgj3/oOFDFwvktu1Ei1ZrwCooCzkROcr0mlGfTQc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21906},"main":"dist/index.js","_from":"file:azhulin-pagination-nestjs-graphql-1.0.0.tgz","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{},"_npmUser":{"name":"azhulin","email":"zhulin.dem@gmail.com"},"_resolved":"/private/var/folders/y0/gfj8tg7s6_56fbbh64kygfpc0000gp/T/4304e7223539604296716154a572acc9/azhulin-pagination-nestjs-graphql-1.0.0.tgz","_integrity":"sha512-DsRT9O10Vgj4zO0r/X3sgr5qRYcbCHwyH7Ip37ZLFpzTH50SXvrzjIxpX/wYoZBO+LIfykM6C18/p/ydaWYETA==","repository":{"url":"git+https://github.com/azhulin/pagination.git","type":"git","directory":"packages/nestjs-graphql"},"_npmVersion":"11.6.2","description":"NestJS code-first GraphQL connection types for @azhulin/pagination-core.","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@azhulin/pagination-core":"^1.0.0","@azhulin/pagination-class-validator":"^1.0.0"},"_hasShrinkwrap":false,"peerDependencies":{"@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0","@nestjs/graphql":"^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0","class-validator":"^0.14.2","reflect-metadata":"^0.1.0 || ^0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/pagination-nestjs-graphql_1.0.0_1784640928705_0.5358789392504215","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@azhulin/pagination-nestjs-graphql","version":"1.1.0","keywords":["pagination","cursor","cursor-pagination","keyset-pagination","offset-pagination","nestjs","graphql","graphql-connections","relay","relay-connections","code-first","apollo","typescript"],"author":{"name":"Alex Zhulin"},"license":"MIT","_id":"@azhulin/pagination-nestjs-graphql@1.1.0","maintainers":[{"name":"azhulin","email":"zhulin.dem@gmail.com"}],"homepage":"https://github.com/azhulin/pagination#readme","bugs":{"url":"https://github.com/azhulin/pagination/issues"},"dist":{"shasum":"f70c8d028121831a8ab75361b4ae229ebca650c2","tarball":"https://registry.npmjs.org/@azhulin/pagination-nestjs-graphql/-/pagination-nestjs-graphql-1.1.0.tgz","fileCount":15,"integrity":"sha512-8qPcOVCTTCEC1VTIbux3tjhDNkuPJXnT+N0QPZEqZ8SiLaxECj5SRqMkALdAomuH59tYl98uzJUIvbNn6FlAvQ==","signatures":[{"sig":"MEUCICL6d1X+7drcyMQYeRk29eICDQ/6j8GiWBJySOYM++PzAiEAuWbklS16+oeprzsjPPQKpiqFujgJjMpOC5zD0krIZT8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21906},"main":"dist/index.js","_from":"file:azhulin-pagination-nestjs-graphql-1.1.0.tgz","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{},"_npmUser":{"name":"azhulin","email":"zhulin.dem@gmail.com"},"_resolved":"/private/var/folders/y0/gfj8tg7s6_56fbbh64kygfpc0000gp/T/298053e5238b44e38dc2e978f93170c5/azhulin-pagination-nestjs-graphql-1.1.0.tgz","_integrity":"sha512-8qPcOVCTTCEC1VTIbux3tjhDNkuPJXnT+N0QPZEqZ8SiLaxECj5SRqMkALdAomuH59tYl98uzJUIvbNn6FlAvQ==","repository":{"url":"git+https://github.com/azhulin/pagination.git","type":"git","directory":"packages/nestjs-graphql"},"_npmVersion":"11.6.2","description":"NestJS code-first GraphQL connection types for @azhulin/pagination-core.","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@azhulin/pagination-core":"^1.1.0","@azhulin/pagination-class-validator":"^1.1.0"},"_hasShrinkwrap":false,"peerDependencies":{"@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0","@nestjs/graphql":"^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0","class-validator":"^0.14.2","reflect-metadata":"^0.1.0 || ^0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/pagination-nestjs-graphql_1.1.0_1784712854924_0.21298855264618366","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@azhulin/pagination-nestjs-graphql","version":"1.2.0","description":"NestJS code-first GraphQL connection types for @azhulin/pagination-core.","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"keywords":["pagination","cursor","cursor-pagination","keyset-pagination","offset-pagination","nestjs","graphql","graphql-connections","relay","relay-connections","code-first","apollo","typescript"],"author":{"name":"Alex Zhulin"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/azhulin/pagination.git","directory":"packages/nestjs-graphql"},"dependencies":{"@azhulin/pagination-class-validator":"^1.2.0","@azhulin/pagination-core":"^1.2.0"},"peerDependencies":{"@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0","@nestjs/graphql":"^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0","class-validator":"^0.14.2","reflect-metadata":"^0.1.0 || ^0.2.0"},"scripts":{},"_id":"@azhulin/pagination-nestjs-graphql@1.2.0","bugs":{"url":"https://github.com/azhulin/pagination/issues"},"homepage":"https://github.com/azhulin/pagination#readme","_integrity":"sha512-DSkS/hfehyCIoGNqTeYdnh9S3OLioOuj7286set0zljLPG00dAjtuTX58xwEphfyLP44S46bySj6ah6gi5L/SQ==","_resolved":"/private/var/folders/y0/gfj8tg7s6_56fbbh64kygfpc0000gp/T/970fc499c36362ab361db260107970a2/azhulin-pagination-nestjs-graphql-1.2.0.tgz","_from":"file:azhulin-pagination-nestjs-graphql-1.2.0.tgz","_nodeVersion":"22.19.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-DSkS/hfehyCIoGNqTeYdnh9S3OLioOuj7286set0zljLPG00dAjtuTX58xwEphfyLP44S46bySj6ah6gi5L/SQ==","shasum":"031166c261c9a62dc268a9023e1cf090d1108e30","tarball":"https://registry.npmjs.org/@azhulin/pagination-nestjs-graphql/-/pagination-nestjs-graphql-1.2.0.tgz","fileCount":15,"unpackedSize":21906,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCID1YnTHHszLuqG6v7Qf0K2ikm6wAdJKH+sUGRm5hNy1zAiEAk1WhNcyATyRVvcKMOyXq3IRrusi+kgDeHBjKoc/Kr1I="}]},"_npmUser":{"name":"azhulin","email":"zhulin.dem@gmail.com"},"directories":{},"maintainers":[{"name":"azhulin","email":"zhulin.dem@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pagination-nestjs-graphql_1.2.0_1784726767343_0.7026243737699589"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-21T13:35:28.572Z","modified":"2026-07-22T13:26:07.618Z","1.0.0":"2026-07-21T13:35:28.829Z","1.1.0":"2026-07-22T09:34:15.046Z","1.2.0":"2026-07-22T13:26:07.477Z"},"bugs":{"url":"https://github.com/azhulin/pagination/issues"},"author":{"name":"Alex Zhulin"},"license":"MIT","homepage":"https://github.com/azhulin/pagination#readme","keywords":["pagination","cursor","cursor-pagination","keyset-pagination","offset-pagination","nestjs","graphql","graphql-connections","relay","relay-connections","code-first","apollo","typescript"],"repository":{"type":"git","url":"git+https://github.com/azhulin/pagination.git","directory":"packages/nestjs-graphql"},"description":"NestJS code-first GraphQL connection types for @azhulin/pagination-core.","maintainers":[{"name":"azhulin","email":"zhulin.dem@gmail.com"}],"readme":"# Pagination (NestJS GraphQL)\n\nNestJS **code-first** GraphQL types for [`@azhulin/pagination-core`](../core) connections — connection, edge, page-info,\nand the connection arguments, wired to the core shapes.\n\n```shell\nnpm i @azhulin/pagination-nestjs-graphql\n```\n\nPeer dependencies: `@nestjs/graphql`, `@nestjs/common`, `class-validator`, `reflect-metadata`.\n\n## Exports\n\n| Export                     | Kind                    | Use                                                            |\n|----------------------------|-------------------------|----------------------------------------------------------------|\n| `ConnectionOutput(Edge)`   | `@ObjectType` mixin     | Build a connection type for an edge type.                      |\n| `ConnectionEdgeOutput(N)`  | `@ObjectType` mixin     | Build an edge type for a node type.                            |\n| `ConnectionPageInfoOutput` | `@ObjectType`           | Page-info type; registers as schema type `ConnectionPageInfo`. |\n| `ConnectionArgsInput`      | `@ArgsType`             | The validated connection arguments as nullable GraphQL fields. |\n| `PaginationModeEnum`       | registered GraphQL enum | The core `PaginationMode`, registered for the schema.          |\n\n## Define the types\n\nGraphQL output classes carry an `Output` suffix and register their schema name **without** it via the `@ObjectType(name)`\nargument (`UserOutput` → `User`), keeping them distinct from the domain `User` the paginator returns. Build the edge and\nconnection with the mixin functions, mapping the framework-neutral node up through each constructor:\n\n```ts\nimport type { Connection, ConnectionEdge } from '@azhulin/pagination-core'\nimport { ArgsType, Field, ObjectType } from '@nestjs/graphql'\nimport { IsNotEmpty } from 'class-validator'\nimport { ConnectionArgsInput, ConnectionEdgeOutput, ConnectionOutput } from '@azhulin/pagination-nestjs-graphql'\nimport { User } from './user.model' // your domain entity — the node the paginator emits\n\n@ObjectType('User')\nexport class UserOutput {\n  @Field()\n  public readonly id!: string\n\n  public constructor(user: User) {\n    this.id = user.id\n  }\n}\n\n@ObjectType('UserEdge')\nexport class UserEdgeOutput extends ConnectionEdgeOutput(UserOutput) {\n  public constructor(edge: ConnectionEdge<User>) {\n    super(edge.cursor, new UserOutput(edge.node))\n  }\n}\n\n@ObjectType('UserConnection')\nexport class UserConnectionOutput extends ConnectionOutput(UserEdgeOutput) {\n  public constructor(connection: Connection<ConnectionEdge<User>>) {\n    super(connection.pageInfo, connection.edges.map((edge) => new UserEdgeOutput(edge)))\n  }\n}\n\n// Add your own filters — ConnectionArgsDto validation comes along.\n@ArgsType()\nexport class UserConnectionArgs extends ConnectionArgsInput {\n  @Field()\n  @IsNotEmpty()\n  public readonly groupId!: string\n}\n```\n\nThe constructors are only there to map the node; when the node the paginator emits is already your GraphQL\n`@ObjectType`, extend with an empty body (`class UserEdgeOutput extends ConnectionEdgeOutput(UserOutput) {}`).\n\nThe page-info type and enum register themselves, producing:\n\n```graphql\ntype UserConnection {\n  pageInfo: ConnectionPageInfo!\n  edges: [UserEdge!]!\n}\n\ntype UserEdge {\n  cursor: String!\n  node: User!\n}\n\ntype ConnectionPageInfo {\n  mode: PaginationMode!\n  hasPreviousPage: Boolean!\n  hasNextPage: Boolean!\n  startCursor: String\n  endCursor: String\n  totalCount: Int\n  page: Int # offset mode only\n  pageSize: Int # offset mode only\n  totalPages: Int # offset mode only\n}\n\nenum PaginationMode {\n  Cursor\n  Offset\n}\n```\n\n## Resolver\n\nThe `UserConnectionOutput` constructor maps the framework-neutral `Connection` onto the GraphQL types, so the resolver\nstays thin — no pagination logic:\n\n```ts\nimport { Args, Query, Resolver } from '@nestjs/graphql'\n\n@Resolver()\nexport class UserResolver {\n  public constructor(private readonly users: UserRepository) {}\n\n  @Query(() => UserConnectionOutput)\n  public async usersByGroup(@Args() args: UserConnectionArgs): Promise<UserConnectionOutput> {\n    // The repository builds a framework-neutral Connection<User> with a core Paginator (+ an adapter such as\n    // @azhulin/pagination-typeorm); the constructor maps it onto the GraphQL types.\n    return new UserConnectionOutput(await this.users.paginateByGroup(args, args.groupId))\n  }\n}\n```\n\nClients send `after`/`before`/`first`/`last` **or** `page`/`pageSize`, plus your own arguments:\n\n```graphql\nquery {\n  usersByGroup(groupId: \"g1\", first: 20, after: \"eyJlbWFpbCI6…\") {\n    pageInfo { hasNextPage endCursor mode }\n    edges { cursor node { id email } }\n  }\n}\n```\n\n### Extra edge / connection fields\n\nWiden a type, then populate it by overriding the matching core hook (`createConnectionEdge` / `createConnection`) on\nyour `Paginator` subclass — or with a standard `@ResolveField`:\n\n```ts\n@ObjectType('UserEdge')\nexport class UserEdgeOutput extends ConnectionEdgeOutput(UserOutput) {\n  @Field()\n  public readonly highlighted!: boolean\n}\n```\n\n## License\n\nMIT © 2022–2026 Alex Zhulin\n","readmeFilename":"README.md"}