Divide fetcher with rest and graphql

This commit is contained in:
goncy
2021-08-25 19:51:15 -03:00
parent d4adfd079f
commit 5d76337f9e
16 changed files with 69 additions and 94 deletions

View File

@@ -19,22 +19,22 @@ export default function getProductOperation({
preview?: boolean
} = {}): Promise<T['data']> {
// Get fetch from the config
const { fetch } = commerce.getConfig(config)
const { storeRestFetch } = commerce.getConfig(config)
// Get a single product
const productPromise = fetch<RawProduct>(
const productPromise = storeRestFetch<RawProduct>(
'GET',
`/me/products/${variables?.slug}`
)
// Get product specs
const specsPromise = fetch<{ Items: RawSpec[] }>(
const specsPromise = storeRestFetch<{ Items: RawSpec[] }>(
'GET',
`/me/products/${variables?.slug}/specs`
).then((res) => res.Items)
// Get product variants
const variantsPromise = fetch<{ Items: RawVariant[] }>(
const variantsPromise = storeRestFetch<{ Items: RawVariant[] }>(
'GET',
`/me/products/${variables?.slug}/variants`
).then((res) => res.Items)