Fix build errors

This commit is contained in:
cond0r
2021-05-13 16:10:09 +03:00
parent e7d0f56e85
commit bff94e73ae
22 changed files with 87 additions and 458 deletions

View File

@@ -9,7 +9,7 @@ const getAllCollections = async (options?: {
let { config, variables = { limit: 25 } } = options ?? {}
config = getConfig(config)
const response = await config.fetchSwell('categories', 'list', { variables })
const response = await config.fetch('categories', 'list', { variables })
const edges = response.results ?? []
const categories = edges.map(

View File

@@ -1,5 +1,5 @@
import { SwellProduct } from '@framework/types'
import { getConfig, SwellConfig } from '../api'
import fetchAllProducts from '../api/utils/fetch-all-products'
type ProductPath = {
path: string
@@ -21,15 +21,14 @@ const getAllProductPaths = async (options?: {
let { config, variables = [{ limit: 100 }] } = options ?? {}
config = getConfig(config)
const products = await fetchAllProducts({
config,
query: 'products',
method: 'list',
variables,
})
const { results } = await config.fetch('products', 'list', [
{
limit: variables.first,
},
])
return {
products: products?.map(({ slug: handle }) => ({
products: results?.map(({ slug: handle }: SwellProduct) => ({
node: {
path: `/${handle}`,
},

View File

@@ -19,7 +19,7 @@ const getAllProducts = async (options: {
}): Promise<ReturnType> => {
let { config, variables = { first: 250 } } = options ?? {}
config = getConfig(config)
const { results } = await config.fetchSwell('products', 'list', [
const { results } = await config.fetch('products', 'list', [
{
limit: variables.first,
},

View File

@@ -18,10 +18,12 @@ const getProduct = async (options: {
let { config, variables } = options ?? {}
config = getConfig(config)
const product = await config.fetchSwell('products', 'get', [variables.slug])
const product = await config.fetch('products', 'get', [variables.slug])
if (product && product.variants) {
product.variants = product.variants?.results
}
return {
product: product ? normalizeProduct(product) : null,
}