mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 03:31:23 +00:00
Merge branch 'nodejs-provider' of https://github.com/vercel/commerce into shopify-updates
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { getConfig, ShopifyConfig } from '../api'
|
||||
import fetchAllProducts from '../api/utils/fetch-all-products'
|
||||
import { ProductEdge } from '../schema'
|
||||
import getAllProductsPathsQuery from '../utils/queries/get-all-products-paths-query'
|
||||
|
||||
type ProductPath = {
|
||||
@@ -19,21 +19,22 @@ const getAllProductPaths = async (options?: {
|
||||
config?: ShopifyConfig
|
||||
preview?: boolean
|
||||
}): Promise<ReturnType> => {
|
||||
let { config, variables = { first: 250 } } = options ?? {}
|
||||
let { config, variables = { first: 100, sortKey: 'BEST_SELLING' } } =
|
||||
options ?? {}
|
||||
config = getConfig(config)
|
||||
|
||||
const products = await fetchAllProducts({
|
||||
config,
|
||||
query: getAllProductsPathsQuery,
|
||||
const { data } = await config.fetch(getAllProductsPathsQuery, {
|
||||
variables,
|
||||
})
|
||||
|
||||
return {
|
||||
products: products?.map(({ node: { handle } }) => ({
|
||||
node: {
|
||||
path: `/${handle}`,
|
||||
},
|
||||
})),
|
||||
products: data.products?.edges?.map(
|
||||
({ node: { handle } }: ProductEdge) => ({
|
||||
node: {
|
||||
path: `/${handle}`,
|
||||
},
|
||||
})
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@ import { getConfig, ShopifyConfig } from '../api'
|
||||
import { GetAllProductsQuery, Product as ShopifyProduct } from '../schema'
|
||||
import { getAllProductsQuery } from '../utils/queries'
|
||||
import { normalizeProduct } from '../utils/normalize'
|
||||
import { Product } from '@commerce/types'
|
||||
import { Product } from '../types/product'
|
||||
|
||||
type Variables = {
|
||||
first?: number
|
||||
|
Reference in New Issue
Block a user