Skip to content

Commit

Permalink
Slightly simplify relayStylePagination read cursor handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Jun 28, 2021
1 parent 25fed77 commit 3899ffe
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/utilities/policies/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,10 @@ export function relayStylePagination<TNode = Reference>(
}
});

let {
const {
startCursor,
endCursor,
} = existing.pageInfo || {};
// If existing.pageInfo.{start,end}Cursor are undefined or "", default to
// firstEdgeCursor and/or lastEdgeCursor.
startCursor = startCursor || firstEdgeCursor;
endCursor = endCursor || lastEdgeCursor;

return {
// Some implementations return additional Connection fields, such
Expand All @@ -129,8 +125,10 @@ export function relayStylePagination<TNode = Reference>(
edges,
pageInfo: {
...existing.pageInfo,
startCursor,
endCursor,
// If existing.pageInfo.{start,end}Cursor are undefined or "", default
// to firstEdgeCursor and/or lastEdgeCursor.
startCursor: startCursor || firstEdgeCursor,
endCursor: endCursor || lastEdgeCursor,
},
};
},
Expand Down

0 comments on commit 3899ffe

Please sign in to comment.