-
Notifications
You must be signed in to change notification settings - Fork 87
Closed
Labels
Status: BlockedSome technical or requirement is blocking the issueSome technical or requirement is blocking the issueType: FeatureNew feature or requestNew feature or request
Description
Hey,
Understand that pagination in GraphQL isn't the same as pagination within REST. One thing that we had to do when using this library is to build our own helper function around how to handle retires/pagination when returning a subset of data which is large.
It would be great if this library could handle some of that an abstract that behind the scenes so we wouldn't have to build our own helper functions which lie on top of this library.
The function we built looked something like this:
const withPagination = (queryFunc, pluckCursor) => async (
client,
variables = {}
) => {
const cursor = variables.cursor || null;
return queryFunc(client, Object.assign({}, variables, { cursor })).then(
async results => {
const intermediate = Array.isArray(results) ? results : [results];
const nextCursor = pluckCursor(results);
if (!nextCursor) {
return intermediate;
}
const nextResults = await withPagination(queryFunc, pluckCursor)(
client,
Object.assign({}, variables, { cursor: nextCursor })
);
return intermediate.concat(nextResults);
}
);
};
We would be happy to contribute back to this package, but first, want to understand your thoughts/motivate towards this feature/use case?
aensley, kevo1ution, milahu, sustained, zhenglaizhang and 20 moregr2m, aensley, kevo1ution, kvz, Purushothaman22 and 2 more
Metadata
Metadata
Assignees
Labels
Status: BlockedSome technical or requirement is blocking the issueSome technical or requirement is blocking the issueType: FeatureNew feature or requestNew feature or request