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

Feature/stale time on query #8313

Closed
wants to merge 29 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bd7bf49
fix: move staleTime from queryObserver to query
TkDodo Nov 18, 2024
22f68d2
fix: do not fetch disabled observers on mount
TkDodo Nov 18, 2024
36f53e7
refactor: always resolve staleTime to a number
TkDodo Nov 18, 2024
d6ff692
refactor: move resolveStaleTime into the query itself
TkDodo Nov 18, 2024
6133fb6
refactor: make 0 per default an invalid timeout
TkDodo Nov 18, 2024
8e31ddd
fix: adjust test
TkDodo Nov 18, 2024
54198b2
chore: leftover
TkDodo Nov 18, 2024
e773cd9
fix: un-set invalidated state if we get a new staleTime
TkDodo Nov 18, 2024
27cf824
fix: also handle the case where staleTime goes from a high number to …
TkDodo Nov 18, 2024
39b81d4
fix: staleTime:Infinity should also un-set `isInvalidated`
TkDodo Nov 18, 2024
6c629ce
chore: remove logs
TkDodo Nov 18, 2024
a57bc55
fix: "silence" update events that happen before queries were added to…
TkDodo Nov 18, 2024
30735d9
fix: there's now an extra update event on the cache (expected)
TkDodo Nov 18, 2024
2747f7e
test: queries are now invalidated with staleTime 0 (expected)
TkDodo Nov 18, 2024
08920a9
test: queries without staleTime are now instantly invalidated (expected)
TkDodo Nov 18, 2024
92a109d
fix: do not call setOptions when getting from `build`
TkDodo Nov 18, 2024
f91fb77
fix: queries without data are always stale
TkDodo Nov 20, 2024
c323017
test: queries without data are always stale, even if the observer is …
TkDodo Nov 20, 2024
4cc1d9b
refactor: re-use variable
TkDodo Nov 20, 2024
b07b3fa
chore: remove a test that makes no sense anymore
TkDodo Nov 20, 2024
d18318f
Merge branch 'main' into feature/staleTime-on-query
TkDodo Nov 20, 2024
057b59e
refactor(query): make sure to always update staleTimeout in the const…
TkDodo Nov 20, 2024
8c1c028
chore: inline leftover
TkDodo Nov 20, 2024
0c4040e
Merge branch 'main' into feature/staleTime-on-query
TkDodo Nov 20, 2024
3ae6bff
feat: warn when there are multiple observers mounted at the same time…
TkDodo Nov 20, 2024
fcea9bf
Merge branch 'main' into feature/staleTime-on-query
TkDodo Nov 20, 2024
33058d1
fix(types): There's no need to define staleTime additionally on Fetch…
TkDodo Nov 22, 2024
6529df2
test: add another case
TkDodo Nov 22, 2024
ce2847c
Merge branch 'main' into feature/staleTime-on-query
TkDodo Nov 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(types): There's no need to define staleTime additionally on Fetch…
…QueryOptions, because staleTime is now an option on the query anyway
TkDodo committed Nov 22, 2024

Verified

This commit was signed with the committer’s verified signature.
blittle Bret Little
commit 33058d1af6a09e578e95341ad5660602adf7b03c
5 changes: 0 additions & 5 deletions packages/query-core/src/types.ts
Original file line number Diff line number Diff line change
@@ -454,11 +454,6 @@ export interface FetchQueryOptions<
'queryKey'
> {
initialPageParam?: never
/**
* The time in milliseconds after data is considered stale.
* If the data is fresh it will be returned from the cache.
*/
staleTime?: StaleTime<TQueryFnData, TError, TData, TQueryKey>
}

export interface EnsureQueryDataOptions<