{"id":13847265,"url":"https://github.com/overnested/nestjs-gql-connections","last_synced_at":"2025-07-10T11:32:58.351Z","repository":{"id":57112439,"uuid":"429162570","full_name":"overnested/nestjs-gql-connections","owner":"overnested","description":"Easy and spec-compliant pagination/connections for your NestJS GraphQL objects.","archived":false,"fork":false,"pushed_at":"2023-12-15T02:35:12.000Z","size":173,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T10:06:02.503Z","etag":null,"topics":["graphql","nestjs","pagination","relay"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/overnested.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-17T18:45:28.000Z","updated_at":"2023-06-21T19:51:57.000Z","dependencies_parsed_at":"2024-08-04T18:12:31.077Z","dependency_job_id":null,"html_url":"https://github.com/overnested/nestjs-gql-connections","commit_stats":null,"previous_names":["exonest/graphql-connections"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/overnested/nestjs-gql-connections","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-gql-connections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-gql-connections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-gql-connections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-gql-connections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overnested","download_url":"https://codeload.github.com/overnested/nestjs-gql-connections/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overnested%2Fnestjs-gql-connections/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260484415,"owners_count":23016116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","nestjs","pagination","relay"],"created_at":"2024-08-04T18:01:14.993Z","updated_at":"2025-07-10T11:32:57.984Z","avatar_url":"https://github.com/overnested.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# GraphQL Connections (Pagination)\n\nThis package is a spec-compliant set of models and utilities based on [Relay's Graphql Cursor Connections Specification](https://relay.dev/graphql/connections.htm) and is created using [Generics](https://docs.nestjs.com/graphql/resolvers#generics)\n\n## Introduction\n\nTo use pagination in GraphQL, it's proposed by the spec that we use the \"Connections\" pattern and expose these connections in a standardized way.\n\n- In queries, you use `PaginationArgs` to slice and paginate the result.\n- In response, you return `Connection` objects to provide cursors and a way to tell the client when more results are available.\n\n## Installation\n\nOn Yarn:\n\n```shell\nyarn add nestjs-gql-connections\n```\n\nOn NPM:\n\n```shell\nnpm install nestjs-gql-connections\n```\n\n## Usage\n\nYou can create a new paginated model like so:\n\n```ts\nimport { Paginated } from 'nestjs-gql-connections';\nimport { Product } from '../product.model';\n\nexport class ProductConnection extends Paginated(Product) {}\n```\n\nNote that for your connection to be compliant to relay's specifications, its name should end with `Connection`. ([reference](https://relay.dev/graphql/connections.htm#sec-Reserved-Types))\n\nTo create a query for a paginated resource, do like so:\n\n```ts\n@Query(() =\u003e ProductConnection)\nresourcePublications(\n    @Args() { after, before, first, last, skip }: PaginationArgs,\n) {\n    // return data based on pagination\n}\n```\n\n## Apollo Cache Compatability\n\nBe default, Apollo server won't cache if a field on resolver is an object (non-scalar), thinking non-scalar fields need fetching and are probably somehow independent ([more info](https://www.apollographql.com/docs/apollo-server/performance/caching/#default-maxage)). While in the case of pagination's `node` object or `edges`, they are already fetched and available. So we've added cache control inheritance to all the respective fields and you don't really have to worry about that. This package goes nicely with the other [overnested](https://github.com/overnested) package for GraphQL caching, [overnested/graphql-cache-control](https://github.com/overnested/nestjs-gql-cache-control)\n\n## With Prisma\n\nIf you use Prisma, there is another spec-compliant package that facilitates returning data as connections: [@devoxa/prisma-relay-cursor-connection](https://github.com/devoxa/prisma-relay-cursor-connection)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovernested%2Fnestjs-gql-connections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovernested%2Fnestjs-gql-connections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovernested%2Fnestjs-gql-connections/lists"}