Skip to main content

๐Ÿ“ฆ 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, descriptionHtml
  • price, compareAtPrice (from first variant)
  • images[], featuredImage
  • variants[]: each with variant-specific metafields
  • Custom metafields if productMetafields, collectionMetafields, or variantMetafields are 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;
}[];
};
caution

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;
};
info

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.