From 3899ffe69e629c8f063fa815ad92552259f5defa Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 28 Jun 2021 19:51:48 -0400 Subject: [PATCH] Slightly simplify relayStylePagination read cursor handling. --- src/utilities/policies/pagination.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/utilities/policies/pagination.ts b/src/utilities/policies/pagination.ts index 525a2f5a7de..e6471b2d99d 100644 --- a/src/utilities/policies/pagination.ts +++ b/src/utilities/policies/pagination.ts @@ -112,14 +112,10 @@ export function relayStylePagination( } }); - 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 @@ -129,8 +125,10 @@ export function relayStylePagination( 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, }, }; },