From 3d2ee58c4d722c1595d6491eedfeac1b28a6a15a Mon Sep 17 00:00:00 2001 From: tniezg Date: Fri, 20 Aug 2021 12:29:27 +0200 Subject: [PATCH] Adjust fetchers to the latest Spree SDK interface --- framework/spree/api/operations/get-all-product-paths.ts | 1 + framework/spree/api/operations/get-all-products.ts | 1 + framework/spree/api/operations/get-product.ts | 1 + framework/spree/product/use-search.tsx | 1 + framework/spree/utils/create-customized-fetch-fetcher.ts | 7 +------ 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/framework/spree/api/operations/get-all-product-paths.ts b/framework/spree/api/operations/get-all-product-paths.ts index 9dab1e2a3..6ea081bb3 100644 --- a/framework/spree/api/operations/get-all-product-paths.ts +++ b/framework/spree/api/operations/get-all-product-paths.ts @@ -58,6 +58,7 @@ export default function getAllProductPathsOperation({ const variables: SpreeSdkVariables = { methodPath: 'products.list', arguments: [ + {}, { fields: { product: 'slug', diff --git a/framework/spree/api/operations/get-all-products.ts b/framework/spree/api/operations/get-all-products.ts index df9c25bd1..5ad76cad1 100644 --- a/framework/spree/api/operations/get-all-products.ts +++ b/framework/spree/api/operations/get-all-products.ts @@ -45,6 +45,7 @@ export default function getAllProductsOperation({ const variables: SpreeSdkVariables = { methodPath: 'products.list', arguments: [ + {}, { include: 'variants,images,option_types,variants.option_values', per_page: first, diff --git a/framework/spree/api/operations/get-product.ts b/framework/spree/api/operations/get-product.ts index 79b799d23..57d43a8f0 100644 --- a/framework/spree/api/operations/get-product.ts +++ b/framework/spree/api/operations/get-product.ts @@ -52,6 +52,7 @@ export default function getProductOperation({ methodPath: 'products.show', arguments: [ getProductVariables.slug, + {}, { include: 'variants,images,option_types,variants.option_values', }, diff --git a/framework/spree/product/use-search.tsx b/framework/spree/product/use-search.tsx index 7cadca277..2945592be 100644 --- a/framework/spree/product/use-search.tsx +++ b/framework/spree/product/use-search.tsx @@ -46,6 +46,7 @@ export const handler: SWRHook = { variables: { methodPath: 'products.list', arguments: [ + {}, { include: 'variants,images,option_types,variants.option_values', per_page: 50, diff --git a/framework/spree/utils/create-customized-fetch-fetcher.ts b/framework/spree/utils/create-customized-fetch-fetcher.ts index 9ed35a82f..4adb64a45 100644 --- a/framework/spree/utils/create-customized-fetch-fetcher.ts +++ b/framework/spree/utils/create-customized-fetch-fetcher.ts @@ -47,7 +47,6 @@ const createCustomizedFetchFetcher: CreateCustomizedFetchFetcher = ( try { const response: Response = await fetch(request) - const data = await response.json() if (!response.ok) { @@ -61,11 +60,7 @@ const createCustomizedFetchFetcher: CreateCustomizedFetchFetcher = ( data: Object.setPrototypeOf({ data }, { response }), } } catch (error) { - if (error instanceof TypeError) { - throw new FetchError(null, request, null) - } - - throw error + throw new FetchError(null, request, null, error.message) } } catch (error) { if (error instanceof FetchError) {