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

RTKQ: configurable structuralSharing on endpoints/queries/createApi #1954

Merged
merged 5 commits into from
Feb 1, 2022

Conversation

msutkowski
Copy link
Member

@msutkowski msutkowski commented Jan 24, 2022

Addresses #1896.

For the example in that issue, there isn't much that can be done outside of just disabling the structural sharing optimization. This PR enables that by adding a flag to createApi, accepting a flag on an individual query endpoint, and allowing a hook/initiate to specify the desired value.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 24, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e7820d1:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration

@github-actions
Copy link

github-actions bot commented Jan 24, 2022

size-limit report 📦

Path Size
1. entry point: @reduxjs/toolkit (cjs.production.min.js) 12.93 KB (0%)
1. entry point: @reduxjs/toolkit (esm.js) 10.79 KB (0%)
1. entry point: @reduxjs/toolkit/query (cjs.production.min.js) 22.65 KB (+0.11% 🔺)
1. entry point: @reduxjs/toolkit/query (esm.js) 19.02 KB (+0.12% 🔺)
1. entry point: @reduxjs/toolkit/query/react (cjs.production.min.js) 24.9 KB (+0.1% 🔺)
1. entry point: @reduxjs/toolkit/query/react (esm.js) 21.71 KB (+0.1% 🔺)
2. entry point: @reduxjs/toolkit (without dependencies) (cjs.production.min.js) 5.71 KB (0%)
2. entry point: @reduxjs/toolkit (without dependencies) (esm.js) 5.67 KB (0%)
2. entry point: @reduxjs/toolkit/query (without dependencies) (cjs.production.min.js) 10.11 KB (+0.24% 🔺)
2. entry point: @reduxjs/toolkit/query (without dependencies) (esm.js) 10.54 KB (+0.2% 🔺)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (cjs.production.min.js) 2.8 KB (0%)
2. entry point: @reduxjs/toolkit/query/react (without dependencies) (esm.js) 3.21 KB (0%)
3. createSlice (esm.js) 5.03 KB (0%)
3. createEntityAdapter (esm.js) 6.28 KB (0%)
3. configureStore (esm.js) 5.65 KB (0%)
3. createApi (esm.js) 17.23 KB (+0.17% 🔺)
3. createApi (react) (esm.js) 19.94 KB (+0.14% 🔺)
3. fetchBaseQuery (esm.js) 11.63 KB (0%)
3. setupListeners (esm.js) 10.42 KB (0%)
3. ApiProvider (esm.js) 18.57 KB (+0.15% 🔺)

@msutkowski
Copy link
Member Author

@phryneas Do you think it's a better idea to consider doing this at the endpoint level as well instead of an all or nothing approach?

@msutkowski msutkowski linked an issue Jan 24, 2022 that may be closed by this pull request
@phryneas
Copy link
Member

Wanted to comment on that one - yes, I'd prefer this as a non-global escape hatch.

@msutkowski
Copy link
Member Author

Wanted to comment on that one - yes, I'd prefer this as a non-global escape hatch.

Alright, updated so that the order of precedence is call site (hook/initiate) flag > endpoint flag > global flag. I was going to remove the global flag, but I do like the flexibility of being able to opt-out, and opt-in very easily.

@msutkowski msutkowski changed the title RTKQ: Add an escape hatch for structural sharing to createApi RTKQ: configurable structuralSharing on endpoints/queries/createApi Jan 25, 2022
@phryneas phryneas merged commit 8c23cd3 into master Feb 1, 2022
@phryneas
Copy link
Member

phryneas commented Feb 3, 2022

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.

[RTKQ]: copyWithStructuralSharing peformance issue
2 participants