i do however, regret to report, that as far as i can tell: it is impossible to run a product query within a specific collection (let alone within a set of collections).
- rather than relying on docs, i had a much better time finding ground-truth by directly experimenting on the GraphiQL app. install the app in your shopify admin and use it, if you’re trying to figure out the storefront graphql api. it’s more complete than the docs.
anyways, as things stand, it looks like we’re very limited in our ability to provide a search experience for users.
from what i can gather, using the storefront graphql api, here are the different viable approaches i can muster, to implement search in a custom storefront for my library:
- fetch everything up-front: (in pages of 250 products at a time)
- this is viable if your store has less than, maybe, a thousand products – beyond that, and the download time and size becomes worrisome
- once everything is downloaded clientside, we can manage the search and filtering entirely ourselves. that can be a good user experience.
- it’s an abomination that shopify might drive us to this, after all, it defeats the entire purpose of pagination (which i have already implemented dutifully)
- duct-tape together the working scraps of shopify’s search api:
- well, there’s no way to run a search/query inside a collection. at all.
- we can give the users a search bar, and checkboxes for tags – and they can use that to search/filter through all products.
- then we can give users the ability to browse collections.
- the key is that users cannot browse collections AND run searches – the interface has to put them in either “browse collections mode”, OR “search mode” – each mode must be mutually exclusive – we can run pagination within each of those modes
for my use-case, building the shopify-shepherd typescript library along with the store ui project sheep-cart, i’ll prefer the paginated duct-tape method, as it’s more robust for bigger stores – but hopefully i’ll have time to implement both modes..