From fc67dd1cca33900fce088b9e1a645e9f0836d0d2 Mon Sep 17 00:00:00 2001 From: Sidhartha Chatterjee Date: Mon, 17 Dec 2018 18:40:32 +0530 Subject: [PATCH 1/2] Add a failing test for #10497 --- .../connection/__tests__/arrayconnection.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/graphql-skip-limit/src/connection/__tests__/arrayconnection.js b/packages/graphql-skip-limit/src/connection/__tests__/arrayconnection.js index 774625bc014b8..70b62c8b55241 100644 --- a/packages/graphql-skip-limit/src/connection/__tests__/arrayconnection.js +++ b/packages/graphql-skip-limit/src/connection/__tests__/arrayconnection.js @@ -150,6 +150,27 @@ describe(`connectionFromArray()`, () => { }, }) }) + + it(`returns hasNextPage correctly`, () => { + const c = connectionFromArray(letters, { limit: 2, skip: 3 }) + return expect(c).toEqual({ + edges: [ + { + next: `E`, + node: `D`, + previous: `C`, + }, + { + next: undefined, + node: `E`, + previous: `D`, + }, + ], + pageInfo: { + hasNextPage: false, + }, + }) + }) }) }) From e9fb0c23f011861c4985cb401a9cf68f6e4832c4 Mon Sep 17 00:00:00 2001 From: Sidhartha Chatterjee Date: Mon, 17 Dec 2018 18:41:40 +0530 Subject: [PATCH 2/2] Fix incorrect expression for hasNextPage --- packages/graphql-skip-limit/src/connection/arrayconnection.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/graphql-skip-limit/src/connection/arrayconnection.js b/packages/graphql-skip-limit/src/connection/arrayconnection.js index 046ad85377875..6fc440b1270c1 100644 --- a/packages/graphql-skip-limit/src/connection/arrayconnection.js +++ b/packages/graphql-skip-limit/src/connection/arrayconnection.js @@ -52,9 +52,7 @@ export function connectionFromArray( edges, pageInfo: { hasNextPage: - typeof limit === `number` - ? limit + startSlice - 1 < data.length - : false, + typeof limit === `number` ? limit + startSlice < data.length : false, }, } }