commerce/lib/shopify/queries/collection.ts
Chloe 145eb3eaed
fix: sort button visual and filter by variant metafield
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
2024-05-07 13:30:26 +07:00

75 lines
1.4 KiB
TypeScript

import productFragment from '../fragments/product';
import seoFragment from '../fragments/seo';
const collectionFragment = /* GraphQL */ `
fragment collection on Collection {
handle
title
description
seo {
...seo
}
updatedAt
}
${seoFragment}
`;
export const getCollectionQuery = /* GraphQL */ `
query getCollection($handle: String!) {
collection(handle: $handle) {
...collection
}
}
${collectionFragment}
`;
export const getCollectionsQuery = /* GraphQL */ `
query getCollections {
collections(first: 100, sortKey: TITLE) {
edges {
node {
...collection
}
}
}
}
${collectionFragment}
`;
export const getCollectionProductsQuery = /* GraphQL */ `
query getCollectionProducts(
$handle: String!
$sortKey: ProductCollectionSortKeys
$reverse: Boolean
$filters: [ProductFilter!]
) {
collection(handle: $handle) {
products(sortKey: $sortKey, filters: $filters, reverse: $reverse, first: 100) {
edges {
node {
...product
}
cursor
}
filters {
id
label
type
values {
id
count
input
label
}
}
pageInfo {
endCursor
startCursor
hasNextPage
}
}
}
}
${productFragment}
`;