bigcommerce / storefront-data-hooks

Hooks for React Storefront UI Components
MIT License
166 stars 36 forks source link

Related products #7

Closed emilkowalski closed 3 years ago

emilkowalski commented 4 years ago

Is there a way to get related products with the getAllProducts hook?

jorgemasta commented 3 years ago

Hey @emilkowalski , you can use a custom GraphQL query to get the related products.

const { products: allProducts } = await getAllProducts({
  query: customGetAllProductsQuery,
  config,
  preview,
})

Here an example of the query could looks like: https://gist.github.com/jorgemasta/fc5b29c59bd66d26ce3d28c1b71130b3