apollo-feature-requests
apollo-feature-requests copied to clipboard
New Pagination helper with custom key value to paginate
Hi, I want to create a new pagination helper where we will passed a custom key-value to paginate for like this one:
import {getOr,set} from 'lodash/fp';
function customPaginationHelper (keyArgs){
keyArgs,
merge: function (existing, incoming) {
if (isNil(existing)) {
return incoming;
} else {
const key = keyArgs[0];
const existingValues = getOr([], key, existing);
const incomingValues = getOr([], key, incoming);
const concatenatedValues = concat(
existingValues,
incomingValues
);
return set(key, concatenatedValues, incoming);
}
},
},
I believe many will benefit from this as I think this is a common pattern. Thanks.