Skip to content

Commit

Permalink
fix(graphql-skip-limit): fix hasNextPage (gatsbyjs#10504)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthachatterjee authored and gpetrioli committed Jan 22, 2019
1 parent 0ed343b commit b94d35e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
})
})
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export function connectionFromArray<T>(
edges,
pageInfo: {
hasNextPage:
typeof limit === `number`
? limit + startSlice - 1 < data.length
: false,
typeof limit === `number` ? limit + startSlice < data.length : false,
},
}
}
Expand Down

0 comments on commit b94d35e

Please sign in to comment.