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

@W-16161754 - [BUG 🐞] Fix useCustomQuery not using throwOnBadResponse argument #1879

Closed
wants to merge 3 commits into from

Conversation

bendvc
Copy link
Collaborator

@bendvc bendvc commented Jul 4, 2024

Description

We recently added the useCustomQuery hook to the commerce-sdk-react library. But we forgot to ensure that we are passing the throwOnBadResponse=true argument. This meant that custom apis that were returning error status codes weren't throwing errors resulting in the hooks query status being a "success" when it should be an "error". This PR fixes this by passing this argument in.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Changes

  • Pass throwOnBadResponse=true to isomorphic helper in useCustomQuery
  • Add tests
  • Update test commerce sdk react project to visualize errors
  • Bump verion
  • Add change log

How to Test-Drive This PR

  • Run the test-commerce-sdk-react project and goto http://localhost:3000/custom-endpoint
  • You should see a some successful response data.
  • Now change line 19 of the pages/use-custom-endpoint.tsx to be apiName: 'hello-world-bad'
  • The page should refresh showing "something is wrong" implying an error was thrown and the "error" object was defined for the query return value.

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)
@bendvc bendvc marked this pull request as ready for review July 4, 2024 21:03
@bendvc bendvc requested a review from a team as a code owner July 4, 2024 21:03
@bendvc bendvc requested a review from kevinxh July 4, 2024 21:03
Copy link
Contributor

@vcua-mobify vcua-mobify left a comment

Choose a reason for hiding this comment

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

Changes look good to me and I can see the error thrown when following the test steps.

@bendvc
Copy link
Collaborator Author

bendvc commented Jul 8, 2024

Moved to #1883

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants