cleanup, add sorting

This commit is contained in:
Greg Hoskin
2021-04-25 14:20:58 -05:00
parent 6a9c6c3bca
commit a409c373c4
52 changed files with 74 additions and 618 deletions

View File

@@ -2,7 +2,6 @@ import { Product } from '@commerce/types'
import { getConfig, SwellConfig } 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 = {
path: string
@@ -21,17 +20,18 @@ const getAllProductPaths = async (options?: {
config?: SwellConfig
preview?: boolean
}): Promise<ReturnType> => {
let { config, variables = { first: 250 } } = options ?? {}
let { config, variables = { limit: 100 } } = options ?? {}
config = getConfig(config)
const products = await fetchAllProducts({
config,
query: getAllProductsPathsQuery,
query: 'products',
method: 'list',
variables,
})
return {
products: products?.map(({ node: { handle } }: ProductEdge) => ({
products: products?.map(({ slug: handle }) => ({
node: {
path: `/${handle}`,
},