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

chore(sqllab): Refactor react-query by redux-toolkit query #23760

Merged
merged 15 commits into from
May 8, 2023

Conversation

justinpark
Copy link
Member

@justinpark justinpark commented Apr 20, 2023

SUMMARY

As a follow-up of discussion, this commit migrates the existing react-query api to redux-toolkit query.

tl;dr

In order to consolidate the multiple state management solution, superset team decided to leverage the redux with toolkit in order to organize the existing redux state.
Redux toolkit also includes the rdk query package which can replace the existing react-query hooks (which is a similar solution to minimize the state of async api request) with a single solution.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

test all sqllab functions that run as expected before

ADDITIONAL INFORMATION

@justinpark justinpark changed the title [chore] Refactor react-query by redux-toolkit query chore(sqllab): Refactor react-query by redux-toolkit query Apr 20, 2023
@justinpark justinpark force-pushed the chore--migrate-to-rtk-query branch 2 times, most recently from 957d0e2 to 227dea5 Compare April 20, 2023 23:11
@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Merging #23760 (b6c2255) into master (cfc70ea) will increase coverage by 0.01%.
The diff coverage is 70.00%.

❗ Current head b6c2255 differs from pull request most recent head 7fc1210. Consider uploading reports for the commit 7fc1210 to get more accurate results

@@            Coverage Diff             @@
##           master   #23760      +/-   ##
==========================================
+ Coverage   68.18%   68.19%   +0.01%     
==========================================
  Files        1941     1941              
  Lines       75241    75286      +45     
  Branches     8158     8178      +20     
==========================================
+ Hits        51306    51345      +39     
+ Misses      21852    21846       -6     
- Partials     2083     2095      +12     
Flag Coverage Δ
javascript 54.53% <70.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/SqlLab/App.jsx 0.00% <0.00%> (ø)
...et-frontend/src/components/TableSelector/index.tsx 81.08% <ø> (+2.70%) ⬆️
superset-frontend/src/views/App.tsx 0.00% <0.00%> (ø)
superset-frontend/src/views/store.ts 78.26% <ø> (ø)
...uperset-frontend/src/hooks/apiResources/schemas.ts 65.62% <66.66%> (-26.69%) ⬇️
superset-frontend/src/hooks/apiResources/tables.ts 71.05% <69.69%> (-13.16%) ⬇️
...frontend/src/components/DatabaseSelector/index.tsx 91.52% <100.00%> (ø)
...perset-frontend/src/hooks/apiResources/queryApi.ts 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @justinpark. I left some first-pass comments.

@justinpark justinpark force-pushed the chore--migrate-to-rtk-query branch 2 times, most recently from aaa3ca2 to c61da36 Compare May 3, 2023 20:09
@justinpark
Copy link
Member Author

@michael-s-molina I fixed all addressed issues. Please take a look

Comment on lines 42 to 49
export const storeWithApi = configureStore({
reducer: {
[api.reducerPath]: api.reducer,
},
middleware: getDefaultMiddleware =>
getDefaultMiddleware().concat(api.middleware),
devTools: false,
});
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export const storeWithApi = configureStore({
reducer: {
[api.reducerPath]: api.reducer,
},
middleware: getDefaultMiddleware =>
getDefaultMiddleware().concat(api.middleware),
devTools: false,
});
const createStore = (initialState: object = {}, reducers: object = {}) =>
configureStore({
preloadedState: initialState,
reducer: {
...(reducers || reducerIndex),
[api.reducerPath]: api.reducer,
},
middleware: getDefaultMiddleware =>
getDefaultMiddleware().concat(api.middleware),
devTools: false,
});
export const defaultStore = createStore();

Comment on lines 72 to 83
const mockStore =
store ??
configureStore({
preloadedState: initialState || {},
preloadedState: initialState,
devTools: false,
reducer: reducers || reducerIndex,
reducer: {
...(reducers || reducerIndex),
[api.reducerPath]: api.reducer,
},
middleware: getDefaultMiddleware =>
getDefaultMiddleware().concat(api.middleware),
});
Copy link
Member

Choose a reason for hiding this comment

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

const mockStore = store ?? createStore(initialState, reducers);

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you @justinpark for the refactor and for addressing the comments!

@justinpark justinpark force-pushed the chore--migrate-to-rtk-query branch from bc81c3e to cc5324f Compare May 8, 2023 16:07
@justinpark justinpark merged commit d96b72d into apache:master May 8, 2023
justinpark added a commit to airbnb/superset-fork that referenced this pull request Jun 6, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XXL 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants