Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/graphql querying #5712

Merged
merged 5 commits into from
Mar 29, 2021
Merged

Bug/graphql querying #5712

merged 5 commits into from
Mar 29, 2021

Conversation

Baroshem
Copy link
Collaborator

@Baroshem Baroshem commented Mar 26, 2021

Related Issues

closes #5692
closes #5693

Short Description of the PR

Correctly throw error when GraphQL query is over the complexity limit. Error is thrown in integration (Commercetools) and can be handled/displayed to the user later if needed.

Screenshots of Visual Changes before/after (if There Are Any)

5692
image

5693
image

Pull Request Checklist

  • I have updated the Changelog (V1) v2 and mentioned all breaking changes in the public API.
  • I have documented all new public APIs and made changes to existing docs mentioning the parts I've changed so they're up to date.
  • I have tested my Pull Request on production build and (to my knowledge) it works without any issues

@coveralls
Copy link

coveralls commented Mar 26, 2021

Pull Request Test Coverage Report for Build 689602295

  • 0 of 4 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+4.1%) to 84.271%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/core/middleware/src/createServer.ts 0 4 0.0%
Totals Coverage Status
Change from base Build 686251374: 4.1%
Covered Lines: 813
Relevant Lines: 950

💛 - Coveralls

@coveralls
Copy link

coveralls commented Mar 26, 2021

Pull Request Test Coverage Report for Build 689689687

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 7 (28.57%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.4%) to 79.698%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/commercetools/api-client/src/api/getProduct/index.ts 2 3 66.67%
packages/core/middleware/src/createServer.ts 0 4 0.0%
Totals Coverage Status
Change from base Build 686251374: -0.4%
Covered Lines: 1503
Relevant Lines: 1750

💛 - Coveralls

@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2021

💙 vsf-next-demo successfully deployed at https://2285ea644fabad3c70f2be2dabea498071b34715.vsf-next-demo.preview.storefrontcloud.io

});
return request;
} catch (error) {
throw error.graphQLErrors?.[0] || error.networkError?.result || error;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this try...catch it give us?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whole try catch allows us to catch an error that is thrown by GraphQL in the terminal but is not handled on the client side. This strange looking throw catches different parts of the error for different problems. The problem with GrapQL query limit is thrown in the NetworkError object of error, while bug with product id lives in GraphQLErrors. Normally it would only throw an error property or the whole error object, but here, with one change two problems can be fixed as they relate to each other.

@Baroshem Baroshem merged commit f023786 into next Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants