๐ฆ FetchCollectionResult Type
The getCollection() function returns a standardized object that includes collection data, products (optional), pagination info, filters, and error handling.
type FetchCollectionResult = {
data: Product[]; // List of products
pageInfo: ProductsPageInfo | null;
availableFilters?: FilterGroup[];
collectionMetafields?: Record<string, any>;
error: string | null;
collection?: {
id: string;
title: string;
handle: string;
descriptionHtml: string;
description: string;
updatedAt: Date | null;
seo: {
title: string | null;
description: string | null;
};
image: {
originalSrc: string;
altText: string | null;
} | null;
};
};
๐๏ธ data: Product[]โ
Array of resolved product objects. Each product may include:
id,title,handle,descriptionHtmlprice,compareAtPrice(from first variant)images[],featuredImagevariants[]: each with variant-specific metafields- Custom metafields if
productMetafields,collectionMetafields, orvariantMetafieldsare provided
โก๏ธ For more details, see the Product Types documentation.
๐ pageInfo: ProductsPageInfoโ
Relay-style cursor-based pagination object.
type ProductsPageInfo = {
hasNextPage: boolean;
hasPreviousPage: boolean;
endCursor: string | null;
startCursor: string | null;
};
Use these values to paginate forward or backward in your UI.
๐งฉ availableFilters?: FilterGroup[]โ
Array of filters available for the current product collection.
Returned only if Shopify filtering is enabled on metafields.
type FilterGroup = {
id: string;
label: string;
values: {
id: string;
label: string;
count: number;
}[];
};
availableFilters only works for metafields configured in Shopify Admin.
You must enable:
- โ Storefront filtering
- โ Storefront API access
Location: Settings โ Custom data โ Products โ [Definition] โ Options
๐๏ธ collectionMetafields?: Record<string, any>โ
Custom metafields resolved for the collection, using collectionMetafields definitions passed to the query.
Returned as camelCase or flat object depending on camelizeKeys option.
๐งพ collection?: { ... }โ
Resolved basic info for the queried collection (title, handle, image, etc). Only available if the collection exists.
type CollectionInfo = {
id: string;
title: string;
handle: string;
descriptionHtml: string;
description: string;
updatedAt: Date | null;
seo: {
title: string | null;
description: string | null;
};
image: {
originalSrc: string;
altText: string | null;
} | null;
};
Due to a known Shopify API issue, description, descriptionHtml, image, and seo fields may return null or empty strings โ even if configured in your Shopify admin.
As a workaround, consider storing critical data in custom collection metafields and fetching them with collectionMetafields.
โ error: string | nullโ
A human-readable error message, if something went wrong.
Always check this before using data, pageInfo, or collection.
Description
Type definition for the getCollection\(\) result structure.