apollo-feature-requests icon indicating copy to clipboard operation
apollo-feature-requests copied to clipboard

New Pagination helper with custom key value to paginate

Open jameskuizon13 opened this issue 5 years ago • 0 comments

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.

jameskuizon13 avatar Aug 06 '20 02:08 jameskuizon13