-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Core Data: The "cacheKey" improvements #34771
Comments
We'll have to treat |
Thanks for the feedback, @jsnajdr. We're already converting comma-separated values into an array and then back to string for the See: gutenberg/packages/core-data/src/queried-data/get-query-parts.js Lines 74 to 83 in 1d93095
I only mentioned
|
There are two levels to consider here Level 1 is gutenberg/packages/data/src/redux-store/metadata/utils.ts Lines 48 to 59 in fb3d84b
I don't think it should know about the core-data-specific selectors, so we're left with layer 2: The gutenberg/packages/core-data/src/resolvers.js Lines 132 to 134 in fb3d84b
It would have to compile the full query in gutenberg/packages/core-data/src/resolvers.js Lines 161 to 164 in fb3d84b
_fields query arg so that this fragment returns before the HTTP request:
gutenberg/packages/core-data/src/resolvers.js Lines 97 to 105 in fb3d84b
The same would be needed in gutenberg/packages/core-data/src/resolvers.js Lines 161 to 166 in fb3d84b
|
I assume you meant "two selector calls", not "two selectors"? I guess it's a matter of how we define the same arguments. It would surely be nice if a selector could say "this is a string" and "this is an http query". Perhaps if it made its own resolution cache key? I'm thinking of something like |
Closing this issue as it doesn't seem to be a priority at the moment. |
Sort
_fields
andinclude
keys valuesBoth keys are normalized using the
getNormalizedCommaSeparable
function, but they aren't sorted. It results in having a different cache key if the order of values is changed, and triggering a new REST API request, even though we're requesting the same data.Example:
Update "hashing" method
Currently, we're using
addQueryArgs
to generate the query cache key "hash." While this method works just fine, it produces extra characters when encoding commas and ampersands.I looked at few popular query libraries, and most of them are using
JSON.stringify()
to create a query cache key. So maybe we should also adopt this method./cc @adamziel , @youknowriad, @jsnajdr
The text was updated successfully, but these errors were encountered: