mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
Divide fetcher with rest and graphql
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
import type { CommerceAPI, CommerceAPIConfig } from '@commerce/api'
|
||||
import { getCommerceApi as commerceApi } from '@commerce/api'
|
||||
import createFetcher from './utils/fetch'
|
||||
import createRestFetcher from './utils/fetch-rest'
|
||||
import createGraphqlFetcher from './utils/fetch-graphql'
|
||||
|
||||
import getAllPages from './operations/get-all-pages'
|
||||
import getPage from './operations/get-page'
|
||||
import getSiteInfo from './operations/get-site-info'
|
||||
import getCustomerWishlist from './operations/get-customer-wishlist'
|
||||
import getAllProductPaths from './operations/get-all-product-paths'
|
||||
import getAllProducts from './operations/get-all-products'
|
||||
import getProduct from './operations/get-product'
|
||||
import { API_URL, CART_COOKIE, CUSTOMER_COOKIE } from '../constants'
|
||||
|
||||
export interface OrdercloudConfig extends Omit<CommerceAPIConfig, 'fetch'> {
|
||||
fetch: <T>(
|
||||
export interface OrdercloudConfig extends CommerceAPIConfig {
|
||||
fetch: any
|
||||
storeRestFetch: <T>(
|
||||
method: string,
|
||||
resource: string,
|
||||
body?: Record<string, unknown>,
|
||||
@@ -26,14 +25,12 @@ const config: OrdercloudConfig = {
|
||||
cartCookie: CART_COOKIE,
|
||||
customerCookie: CUSTOMER_COOKIE,
|
||||
cartCookieMaxAge: 2592000,
|
||||
fetch: createFetcher(() => getCommerceApi().getConfig()),
|
||||
storeRestFetch: createRestFetcher(() => getCommerceApi().getConfig()),
|
||||
fetch: createGraphqlFetcher(() => getCommerceApi().getConfig()),
|
||||
}
|
||||
|
||||
const operations = {
|
||||
getAllPages,
|
||||
getPage,
|
||||
getSiteInfo,
|
||||
getCustomerWishlist,
|
||||
getAllProductPaths,
|
||||
getAllProducts,
|
||||
getProduct,
|
||||
|
Reference in New Issue
Block a user