-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
refactor: introduce react-query on api resource hook #21240
refactor: introduce react-query on api resource hook #21240
Conversation
I'm always a fan of using good open-source solution sooner than later. :) |
Codecov Report
@@ Coverage Diff @@
## master #21240 +/- ##
==========================================
- Coverage 66.43% 66.43% -0.01%
==========================================
Files 1784 1786 +2
Lines 68185 68190 +5
Branches 7265 7270 +5
==========================================
+ Hits 45298 45300 +2
Misses 21018 21018
- Partials 1869 1872 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
2cb1007
to
506548d
Compare
SUMMARY
#13218 introduced a hook for api resources. The main purpose of the hook is for a state management for async api request and transformed a return data to a desired format. As @ktmud suggested, react-query includes these specs and also provides the global cache storage.
This commit introduces
react-query
to design a new api resource for tables query first.With the react-query hook, sqlLab can skip the duplicate request for table list on switching each tab. (And it can save the request table query in dataset configuration modal)
After this commit merged, we can replace existing charts and database hooks by
react-query
too.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
-Before:
before--react-query.mov
after--react-query.mov
TESTING INSTRUCTIONS
unit tests
ADDITIONAL INFORMATION
cc: @suddjian