Skip to content

Commit

Permalink
Merge pull request #5712 from vuestorefront/bug/graphql-querying
Browse files Browse the repository at this point in the history
Bug/graphql querying
  • Loading branch information
Baroshem committed Mar 29, 2021
2 parents 3f61ee2 + f8428fb commit f023786
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/commercetools/api-client/src/api/getProduct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ const getProduct = async (context, params, customQuery?: CustomQuery) => {
customQuery, { products: { query: defaultQuery, variables: defaultVariables } }
);

const request = await (context.client as ApolloClient<any>).query<ProductData>({
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<any>).query<ProductData>({
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;
8 changes: 8 additions & 0 deletions packages/core/docs/changelog/5692.js
Original file line number Diff line number Diff line change
@@ -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'
};
8 changes: 8 additions & 0 deletions packages/core/docs/changelog/5693.js
Original file line number Diff line number Diff line change
@@ -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'
};

0 comments on commit f023786

Please sign in to comment.