-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search Not Paginating in Demo Store #596
Comments
I'd love to know why we must assign the endCursor as a key value pair, rather than just passing the variable. Have we uncovered a bug with the storefront API here? |
Hi @jadamconnor, thank you for reporting this issue! We are planning to build a packaged pagination abstraction very soon. This should be resolved when that releases. |
In my case, after clicking Load More, the loader returns zero product nodes even though there are more. The cause was an invalid url as pointed out by @jadamconnor where there was a double '?' in it. A quick fix was to add these checks in ProductGrid.tsx. Also included is the check whether data is a products or collections object.
|
What is the location of your example repository?
No response
What version of Hydrogen are you using?
2023.1.5
What version of Remix are you using?
No response
Steps to Reproduce
Visit Hydrogen demo store, search, and attempt to load more results by clicking "Load more" button.
Expected Behavior
The page should show the next page of GraphQL results.
Actual Behavior
The page displays an error related to the shape of the
ProductGrid
component's collection prop.ProductGrid
accepts acollection
object prop, but the search page passes it aproducts
object, which isn't necessarily of the same shape. Working around this is easy enough but reveals a two more issues.First, if the path passed to the
fetcher
inProductGrid
includes theindex
route param, then theq
param is passed along with theindex
param like so: "snowboards?index", so we have to remove?index
from the path passed tofetcher
.This reveals a new issue: the "Load more" button simply fetches the same page over and over. This is resolved by changing the
cursor
variable passed to the storefront query in the search page's loader toafter: cursor
, but I'm not sure why.In short, the fix is:
ProductGrid
to be more generic.search
. The offending code for this is here.The text was updated successfully, but these errors were encountered: