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, + }, + }) + }) }) }) 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, }, } }