forked from crowetic/commerce
Minor fixes
This commit is contained in:
parent
9c1372acb7
commit
5bf93038c2
@ -53,6 +53,13 @@ export type GetAllProductsResult<
|
||||
T extends Record<keyof GetAllProductsResult, any[]> = { products: Products }
|
||||
> = T
|
||||
|
||||
const FIELDS = [
|
||||
'products',
|
||||
'featuredProducts',
|
||||
'bestSellingProducts',
|
||||
'newestProducts',
|
||||
]
|
||||
|
||||
export type ProductTypes =
|
||||
| 'products'
|
||||
| 'featuredProducts'
|
||||
@ -92,21 +99,14 @@ async function getAllProducts({
|
||||
...vars,
|
||||
}
|
||||
|
||||
switch (field) {
|
||||
case 'products':
|
||||
variables.products = true
|
||||
break
|
||||
case 'featuredProducts':
|
||||
variables.featuredProducts = true
|
||||
break
|
||||
case 'bestSellingProducts':
|
||||
variables.bestSellingProducts = true
|
||||
break
|
||||
case 'newestProducts':
|
||||
variables.newestProducts = true
|
||||
break
|
||||
if (!FIELDS.includes(field)) {
|
||||
throw new Error(
|
||||
`The field variable has to match one of ${FIELDS.join(', ')}`
|
||||
)
|
||||
}
|
||||
|
||||
variables[field] = true
|
||||
|
||||
// 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<RecursivePartial<GetAllProductsQuery>>(
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { BigcommerceApiError } from '../../utils/errors'
|
||||
import type { Wishlist, WishlistHandlers } from '..'
|
||||
|
||||
// Return wishlist info
|
||||
|
Loading…
x
Reference in New Issue
Block a user