MergedJustin Torre merged 1 commit into main from paginate-products
JTJustin Torreopened this
GET /products returned the first 100 active products and stopped there. The catalog page shows 24 at a time and the merchant is past 100, so this adds paging.
What changes
GET /products takes ?limit= (1 to 100, default 24) and ?after=, and returns { products, next }. next is null on the last page.
The cursor is the (name, id) of the last product on the page, base64url encoded. The query continues with (name, id) > (?, ?) on the existing products_by_name index, so every page is one range scan and pages do not shift when a product is added or retired between requests.
A bad limit or a cursor that does not decode is a 400 (bad_limit, bad_cursor).
The catalog note in the knowledge base has a Paging section.
Compatibility
The response gains next. A client that ignores it now gets the first 24 products instead of up to 100, so the catalog page has to follow next to show more.
Testing
npm test covers three full pages, products sharing a name, a product added before the cursor, and bad parameters.
Justin Torre merged commit 94db762 into main and deleted paginate-products
Merged
Merged into main
Justin Torre merged as 94db762(create a merge commit).
GET /productsreturned the first 100 active products and stopped there. The catalog page shows 24 at a time and the merchant is past 100, so this adds paging.What changes
GET /productstakes?limit=(1 to 100, default 24) and?after=, and returns{ products, next }.nextis null on the last page.(name, id)of the last product on the page, base64url encoded. The query continues with(name, id) > (?, ?)on the existingproducts_by_nameindex, so every page is one range scan and pages do not shift when a product is added or retired between requests.limitor a cursor that does not decode is a 400 (bad_limit,bad_cursor).Compatibility
The response gains
next. A client that ignores it now gets the first 24 products instead of up to 100, so the catalog page has to follownextto show more.Testing
npm testcovers three full pages, products sharing a name, a product added before the cursor, and bad parameters.