https://github.com/binzcodes/graphql-simple-pagination
Provides input and resolver helpers to implement super-simple application-layer paging.
https://github.com/binzcodes/graphql-simple-pagination
graphql pagination
Last synced: 3 months ago
JSON representation
Provides input and resolver helpers to implement super-simple application-layer paging.
- Host: GitHub
- URL: https://github.com/binzcodes/graphql-simple-pagination
- Owner: binzcodes
- Created: 2022-05-21T17:32:11.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-05-05T20:52:50.000Z (about 1 year ago)
- Last Synced: 2025-09-25T13:59:11.834Z (9 months ago)
- Topics: graphql, pagination
- Language: JavaScript
- Homepage:
- Size: 365 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraphQL Simple Pagination
[](https://gitpod.io/#https://github.com/binzcodes/pulumi-minimal-dynamodb-api)
A simple pagination helper for GraphQL.
`npm install --save graphql-simple-pagination`
*graphql-simple-pagination* provides input and resolver helpers
to implement super-simple application-layer paging.
#### Usage
```javascript
const { paginationInputType, paginationResolver } = require('graphql-simple-pagination')
const User = new GraphQLObjectType({
name: 'User',
fields: () => ({
// ...
comments: {
type: CommentType,
args: {
pagination: {
type: paginationInputType
}
},
resolve: (user, args) => paginationResolver(user.comments, args.pagination)
})
```
#### API
```javascript
const data = [{...}, ...]
const args = {
rowsPerPage: 10, // number of items per page
page: 0, // page number
sortBy: null, // key to sort by
descending: false // default sort ascent
}
const opts = {
indexOffset: 0 // [0,-1] offsets page number to zero out index
}
let result = paginationResolver(data, args, opts)
console.log(result)
```
# contributing
Planned port to Typescript, contributions welcome
[](https://gitpod.io/#https://github.com/binzcodes/pulumi-minimal-dynamodb-api)