GraphQL pagination helper that makes it easy to get pagination response.
Support only MYSQL and POSTGRESQL databases with Sequelize and also MONGODB with Mongoose
npm install graphql-paginate
- skip : Number
- after : Any
- before : Any
- first : Number
- last : Number
- limit : number
- _where : object
const pagination = require("graphql-paginate");
module.exports = async function getTransactions(parent, args, context) {
const { db } = context;
const { UserTransaction } = db;
return pagination({
model: UserTransaction,
args,
attribute: "id",
orderBy: "DESC",
});
};
{
"pageInfo": {
"endCursor": 2,
"hasNextPage": true,
"hasPreviousPage": true,
"startCursor": 1,
},
"edges": Array [
{
"cursor": 1,
"node": {
"id": 1,
"name": "user 1",
},
},
{
"cursor": 2,
"node": {
"id": 2,
"name": "user 2",
},
},
],
"totalCount": 5,