Files
Rami BitarandClaude Opus 5 3bc61066f0 Add collections pagination and a search field on the search page
Paginate the collections grid with a "See more" button backed by a new
getCollectionsPage cursor API, add an editable search input to the
search-results block, and bump @shopify/hydrogen to 2026.10.0-preview.1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqFkSaLYRPZ18dsMbzjiP4
2026-08-23 11:01:48 -04:00

94 lines
1.7 KiB
TypeScript

import { gql } from '@shopify/hydrogen';
import { ProductFragment } from '@/graphql/products';
export const GET_COLLECTIONS_QUERY = gql(`
query GetCollections(
$first: Int!
$after: String
$country: CountryCode
$language: LanguageCode
) @inContext(country: $country, language: $language) {
collections(first: $first, after: $after) {
edges {
node {
id
title
handle
description
descriptionHtml
image {
id
url
altText
width
height
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
`);
export const GET_COLLECTION_PRODUCTS_QUERY = gql(
`
query GetCollectionProducts(
$handle: String!
$first: Int!
$after: String
$sortKey: ProductCollectionSortKeys
$reverse: Boolean
$filters: [ProductFilter!]
$country: CountryCode
$language: LanguageCode
) @inContext(country: $country, language: $language) {
collection(handle: $handle) {
id
title
handle
description
descriptionHtml
image {
id
url
altText
width
height
}
products(
first: $first
after: $after
sortKey: $sortKey
reverse: $reverse
filters: $filters
) {
filters {
id
label
type
values {
id
label
count
input
}
}
edges {
node {
...ProductFragment
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
`,
[ProductFragment]
);