Skip to content

Commit ea56c49

Browse files
sidharthachatterjeepieh
authored andcommitted
fix(graphql-skip-limit): fix hasNextPage (#10504)
1 parent fa2b50e commit ea56c49

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

packages/graphql-skip-limit/src/connection/__tests__/arrayconnection.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,27 @@ describe(`connectionFromArray()`, () => {
150150
},
151151
})
152152
})
153+
154+
it(`returns hasNextPage correctly`, () => {
155+
const c = connectionFromArray(letters, { limit: 2, skip: 3 })
156+
return expect(c).toEqual({
157+
edges: [
158+
{
159+
next: `E`,
160+
node: `D`,
161+
previous: `C`,
162+
},
163+
{
164+
next: undefined,
165+
node: `E`,
166+
previous: `D`,
167+
},
168+
],
169+
pageInfo: {
170+
hasNextPage: false,
171+
},
172+
})
173+
})
153174
})
154175
})
155176

packages/graphql-skip-limit/src/connection/arrayconnection.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ export function connectionFromArray<T>(
5252
edges,
5353
pageInfo: {
5454
hasNextPage:
55-
typeof limit === `number`
56-
? limit + startSlice - 1 < data.length
57-
: false,
55+
typeof limit === `number` ? limit + startSlice < data.length : false,
5856
},
5957
}
6058
}

0 commit comments

Comments
 (0)