apollo-feature-requests
apollo-feature-requests copied to clipboard
Apollo-client offsetLimitPagination only support key 'limit' but I need skipTakePagination.
Apollo-client offsetLimitPagination only support offset and limit keys but my backend configurated take and skip keys. so how do you think using the offsetLimitPagination's second argument as a key? like this
export function offsetLimitPagination<T = Reference>(
keyArgs: KeyArgs = false,
offsetKey = 'offset'
): FieldPolicy<T[]> {
return {
keyArgs,
merge(existing, incoming, { args }) {
const merged = existing ? existing.slice(0) : [];
if (args) {
// const { offset = 0 } = args; // this line
const offset = args[offsetKey] // to this line
for (let i = 0; i < incoming.length; ++i) {
merged[offset + i] = incoming[i];
}
} else {
merged.push.apply(merged, incoming);
}
return merged;
},
};
}
// Usage
offsetLimitPagination(false, 'skip')
then we can support every offsetLimitPagination that use other keys