mirror of
https://github.com/vercel/commerce.git
synced 2025-07-24 10:41:23 +00:00
Refactor API for getProduct and getAllProductPaths
Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
@@ -39,12 +39,17 @@ export default function getAllProductPathsOperation({
|
||||
// RecursivePartial forces the method to check for every prop in the data, which is
|
||||
// required in case there's a custom `query`
|
||||
const { data } = await config.fetch<CatalogItem>(query, {
|
||||
variables,
|
||||
variables: {
|
||||
...variables,
|
||||
shopIds: [config.shopId],
|
||||
},
|
||||
})
|
||||
const products = data.products.items
|
||||
const products = data.catalogItems?.edges
|
||||
|
||||
return {
|
||||
products: products.map((p) => ({ path: `/${p.slug}` })),
|
||||
products: products.map(({ node }) => ({
|
||||
path: `/${node.product?.slug}`,
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user