diff --git a/packages/commercetools/api-client/src/api/getProduct/index.ts b/packages/commercetools/api-client/src/api/getProduct/index.ts index 0f82c51efa..e34b2bea8d 100644 --- a/packages/commercetools/api-client/src/api/getProduct/index.ts +++ b/packages/commercetools/api-client/src/api/getProduct/index.ts @@ -26,14 +26,19 @@ const getProduct = async (context, params, customQuery?: CustomQuery) => { customQuery, { products: { query: defaultQuery, variables: defaultVariables } } ); - const request = await (context.client as ApolloClient).query({ - query: gql`${products.query}`, - variables: products.variables, - // temporary, seems like bug in apollo: - // @link: https://github.com/apollographql/apollo-client/issues/3234 - fetchPolicy: 'no-cache' - }); - return request; + try { + const request = await (context.client as ApolloClient).query({ + query: gql`${products.query}`, + variables: products.variables, + // temporary, seems like bug in apollo: + // @link: https://github.com/apollographql/apollo-client/issues/3234 + fetchPolicy: 'no-cache' + }); + return request; + } catch (error) { + throw error.graphQLErrors?.[0] || error.networkError?.result || error; + } + }; export default getProduct; diff --git a/packages/core/docs/changelog/5692.js b/packages/core/docs/changelog/5692.js new file mode 100644 index 0000000000..40f669628f --- /dev/null +++ b/packages/core/docs/changelog/5692.js @@ -0,0 +1,8 @@ +module.exports = { + description: 'add error handling for GraphQL queries with complexity over limit', + link: 'https://github.com/vuestorefront/vue-storefront/issues/5692', + isBreaking: false, + breakingChanges: [], + author: 'Baroshem', + linkToGitHubAccount: 'https://github.com/Baroshem' +}; diff --git a/packages/core/docs/changelog/5693.js b/packages/core/docs/changelog/5693.js new file mode 100644 index 0000000000..d38d65f87f --- /dev/null +++ b/packages/core/docs/changelog/5693.js @@ -0,0 +1,8 @@ +module.exports = { + description: 'extend #5692 thrown error to fix also this issue', + link: 'https://github.com/vuestorefront/vue-storefront/issues/5693', + isBreaking: false, + breakingChanges: [], + author: 'Baroshem', + linkToGitHubAccount: 'https://github.com/Baroshem' +};