Skip to content

Commit a3357dc

Browse files
authored
fix: getDocumentIds pagination query if custom _id values are used (#208)
1 parent 9921390 commit a3357dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/gatsby-node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ const getDocumentIds = async (client: SanityClient): Promise<string[]> => {
201201
while (true) {
202202
const batch = await client.fetch<string[]>(
203203
prevId !== undefined
204-
? `*[!(_type match "system.**") && _id > $prevId][0...$batchSize]._id`
205-
: `*[!(_type match "system.**")][0...$batchSize]._id`,
204+
? `*[!(_type match "system.**") && _id > $prevId]|order(_id asc)[0...$batchSize]._id`
205+
: `*[!(_type match "system.**")]|order(_id asc)[0...$batchSize]._id`,
206206
{
207207
prevId: prevId || null,
208208
batchSize,

0 commit comments

Comments
 (0)