query all products for vendors & paths, improve search

This commit is contained in:
cond0r
2021-02-12 09:56:03 +02:00
parent 1450492826
commit 8d801ce5d7
20 changed files with 315 additions and 126 deletions

View File

@@ -1,4 +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'
@@ -9,21 +10,19 @@ type ReturnType = {
const getAllProductPaths = async (options?: {
variables?: any
config?: ShopifyConfig
previe?: boolean
preview?: boolean
}): Promise<ReturnType> => {
let { config, variables = { first: 250 } } = options ?? {}
config = getConfig(config)
const { data } = await config.fetch(getAllProductsPathsQuery, {
const products = await fetchAllProducts({
config,
query: getAllProductsPathsQuery,
variables,
})
const edges = data?.products?.edges
const productInfo = data?.products?.productInfo
const hasNextPage = productInfo?.hasNextPage
return {
products: edges?.map(({ node: { handle } }: ProductEdge) => ({
products: products?.map(({ node: { handle } }: ProductEdge) => ({
node: {
path: `/${handle}`,
},