feat: Add indexes to Entity for improved performance #237
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #232.
Motivation
Sometimes you want to request data via different parameters.
Say you have user data. It has both an
id
and ausername
. When someone visits their profile you want to have the url have the username. Thus it would be best to look it up via that username. So you add an endpoint that supports that.Unfortunately, because username is not the primary key, this cannot be inferred from entity cache alone. This means if we visited a user list page, then went to that user's profile page - we would have to wait while the new request finishes. This is quite silly, as a request with the primary key would instantly resolve (one of the unique benefits of Rest Hooks).
Solution
Now you can:
And get results before the fetch completes!
Note: Inferred results are always considered stale and will revalidate when
useResource()
.