UNPKG

@shopify/hydrogen-react

Version:

React components, hooks, and utilities for creating custom Shopify storefronts

20 lines (19 loc) 756 B
import type { PartialDeep } from 'type-fest'; /** * The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](https://shopify.dev/api/storefront/reference/products/product)) into a flat array of nodes. * The utility works with either `nodes` or `edges.node`. * * If `connection` is null or undefined, will return an empty array instead in production. In development, an error will be thrown. */ export declare function flattenConnection<T>(connection?: PartialDeep<GraphQLConnection<T>, { recurseIntoArrays: true; }>): PartialDeep<T, { recurseIntoArrays: true; }>[]; interface GraphQLConnection<T> { edges?: { node: T; }[]; nodes?: T[]; } export {};