0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
Commit graph

5,038 commits

Author SHA1 Message Date
Jonghyeon Ko
786beac4b1
chore: update Node version and modify script commands (#9286)
- Updated Node version in .nvmrc from 22.12.0 to 24.2.0.
- Changed the "verify-links" script in package.json to use "node" instead of "pnpm tsx".
- Removed tsx dependency from package.json and pnpm-lock.yaml.
2025-06-18 19:52:28 +02:00
Jonghyeon Ko
cdab6e2b2b
ci: add link verification step to PR workflow (#9267) 2025-06-19 01:28:16 +09:00
Konrad Lisiczyński
5b017d1a68
docs: Update community-projects.md (#9285)
I just added `@normy/vue-query` addon to normy.

Also, I added `@normy/query-core` addon and refactored `@normy/react-query` to use it, so it would be very easy to add more addons, like to angular, solid and so on
2025-06-18 18:05:29 +02:00
Tanner Linsley
ddc15f7efa release: v5.80.9 v5.80.9 2025-06-17 21:57:31 +00:00
Arnoud
e292e3e5cf
fix(angular-query): fix types missing in published package (#9283) 2025-06-17 23:55:23 +02:00
Arnoud
c251358624
Revert "refactor(angular-query): migrate from tsup to vite (#9281)" (#9282)
This reverts commit 1c7c276a54.
2025-06-17 23:37:10 +02:00
Tanner Linsley
6f519975d6 release: v5.80.8 v5.80.8 2025-06-17 18:14:33 +00:00
Arnoud
1c7c276a54
refactor(angular-query): migrate from tsup to vite (#9281)
* chore(angular-query): migrate from tsup to vite

* build fixes
2025-06-17 20:03:50 +02:00
Tanner Linsley
33d008bbb3 release: v5.80.7 v5.80.7 2025-06-11 23:52:08 +00:00
Wesley LeMahieu
bd3ac49e29
fix(solid-query-devtools): client-side code instantiating prematurely server-side (#9163)
* separate concerns of clientOnly and SolidQueryDevtools

* remove unnecessary type change
2025-06-12 01:49:17 +02:00
renovate[bot]
641ec86053
chore(deps): update autofix-ci/action digest to 635ffb0 (#9263)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-09 22:21:24 +10:00
Collin Stevens
cba46b5d79
docs: fix relative links (#9262)
* fix relative links

* Update mutations.md
2025-06-09 09:11:45 +02:00
H. C. Kruse
10b4c2fbe5
docs: Remove superfluous text from mutations.md (#9256)
Sentence ends in `Add commentMore actions` looking out of place.
2025-06-06 15:37:37 +02:00
Christina Martinez
eae7bde328
docs: Replace accidentally-deleted content in mutations.md (#9254)
Co-authored-by: christinamartinez <christina.martinez@faithlife.com>
2025-06-06 09:14:14 +02:00
Braden Wong
2b9b122b98
test: add callback return type tests for mutation callbacks (#9252)
* Revert "refactor(types): narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)"

This reverts commit 982f6ca607.

* test: add callback return type tests for mutation callbacks

Adds test coverage for mutation callback return types, inspired by the discussions and [TkDodo's comment](https://github.com/TanStack/query/pull/9245#issuecomment-2939664588
) in #9245 and the original Promise.all() edge case identified in #9202.

The original PR #9202 narrowed callback return types from `Promise<unknown> | unknown`
to `Promise<void> | void`, but this broke common patterns like:

```ts
onSuccess: (data) => Promise.all([
  invalidateQueries(),
  trackAnalytics(),
])
```

As noted in [the original discussion](https://github.com/TanStack/query/pull/9202#issuecomment-2934491122),
this `Promise.all()` pattern was a legitimate use case that many users relied on.

These tests ensure we support all the callback patterns that users expect:

✅ **Sync patterns**: Implicit void, explicit void, non-void returns
✅ **Async patterns**: Async functions, Promise.resolve(), Promise<T> returns
✅ **Promise.all() patterns**: The original breaking case from #9202
✅ **Promise.allSettled() patterns**: Additional parallel operation support
✅ **Mixed patterns**: Different callback types in same mutation
✅ **Error handling**: All patterns work in error scenarios
✅ **Return value isolation**: Callback returns don't affect mutation result

* refactor(tests): remove unnecessary parameters in mutation tests

* test(mutations): fix mutation test ordering with error handling and cleanup verification

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-06-05 17:20:23 +02:00
Tanner Linsley
433599301c release: v5.80.6 v5.80.6 2025-06-05 13:09:53 +00:00
Braden Wong
dfbda9de66
refactor(types): revert narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)" (#9251)
This reverts commit 982f6ca607.
2025-06-05 15:04:37 +02:00
Tanner Linsley
2db48f44b3 release: v5.80.5 v5.80.5 2025-06-04 18:43:11 +00:00
René Klomp
9e0e60c7f0
fix(experimental_createQueryPersister): Change persisterRestoreAll to restoreQueries with filter support (#9230)
* Add persisterRestoreByKey

* Fix imports

* Add missing return statement

* Fix test

* docs

* Add extra test

* Merge into single restoreQueries function
2025-06-04 20:37:26 +02:00
Tanner Linsley
baaa3104d2 release: v5.80.4 v5.80.4 2025-06-04 18:20:29 +00:00
Damian Osipiuk
fc92ef9fa3
fix(vue-query): make vue-query client compatible with query-core (#9250)
* fix(vue-query): make vue-query client compatible with query-core

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-06-04 20:18:05 +02:00
Jinhyun Park
838acecbe5
docs(readme): replace invalid _build image paths with public asset URLs (#9248)
- Replaced sponsor image paths that pointed to `_build/assets/...` (invalid in GitHub markdown context)
- Updated to use public URLs (`https://tanstack.com/assets/...`) to prevent broken images
2025-06-04 11:55:46 +02:00
Tanner Linsley
4f4c2c7540 release: v5.80.3 v5.80.3 2025-06-04 09:49:05 +00:00
Fredrik Höglund
0d2c2e0fb2
fix(react-query): move hydrationQueue from state to a derived value (#9247) 2025-06-04 11:44:20 +02:00
메타몽닮음
058bfc9735
docs(contributing): update pnpm version and fix typo (#9243) 2025-06-04 01:20:14 +09:00
Tanner Linsley
37eda0d7d9 release: v5.80.2 v5.80.2 2025-06-03 12:08:50 +00:00
Jongwan Lee
5e3cd46aaa
fix(query-core): correct error handling in tryResolveSync function (#9206) 2025-06-03 14:04:18 +02:00
Tanner Linsley
9c6fb061a5 release: v5.80.1 v5.80.1 2025-06-03 11:23:36 +00:00
novice0840
57c6ce149b
perf: improve performance of util function "difference" in quriesObserver.ts in query-core package (#9201)
* perf: change "difference" util function

* refactor: extract "new Set" function in "difference" util function
2025-06-03 13:18:02 +02:00
Tanner Linsley
8d41a4ea78 release: v5.80.0 v5.80.0 2025-06-03 09:36:24 +00:00
Braden Wong
1fba7fc38b
chore: consolidate noop function usage across framework packages (#9228)
Multiple framework-specific packages (`solid-query`, `svelte-query`, and `angular-query-experimental`) were maintaining their own implementations of the `noop` function, creating unnecessary code duplication across the codebase.

```typescript
// Before: Each package had its own noop
// packages/svelte-query/src/utils.ts
export function noop(): void {}

// packages/solid-query/src/utils.ts (missing, causing import errors)
// Local noop definitions scattered across files
```

Consolidated all `noop` usage to import from the canonical implementation in `@tanstack/query-core`, which all framework packages already depend on.

```typescript
// After: Single source of truth
import { noop } from '@tanstack/query-core'
```

- **Removed duplicate `noop` definition** from `packages/svelte-query/src/utils.ts`
- **Updated import statements** in Solid Query and Svelte Query to use `noop` from `@tanstack/query-core`
- **Fixed missing utils file** in Solid Query that was causing import errors
- **Resolved TypeScript compatibility** issues with `noop`'s overloaded return types

- **Persisters were intentionally left unchanged** as they don't import `query-core` and maintain their own lightweight utils
- **Framework packages already depend on `query-core`**, making this consolidation natural and dependency-free
2025-06-03 11:31:33 +02:00
Braden Wong
efa963d1fd
refactor(types): remove unnecessary TQueryData generic in InfiniteQueryObserverOptions (#9224)
* refactor(core): remove unnecessary TQueryData in InfiniteQueryObserverOptions

* refactor(react-query,solid-query,svelte-query,vue-query,angular-query): remove unnecessary TQueryData in InfiniteQueryObserverOptions

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-06-02 19:34:28 +02:00
clonemycode
a2a23a89a3
chore: remove redundant word in comment (#9231)
Signed-off-by: clonemycode <clonecode@aliyun.com>
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-06-03 02:32:03 +09:00
novice0840
4bf169e7c3
refactor(query-core): add "Set" instead of "includes" (#9221) 2025-06-02 19:13:53 +02:00
Braden Wong
3a89ec9c5b
chore: improve type safety in getQueryData by using generics (#9218)
Refactored the `getQueryData` method in `QueryClient` to use generics for type inference instead of type assertion with `as`.

The previous implementation of `getQueryData` relied on a type assertion (`as`) to cast the result of `queryCache.get()`:

```typescript
    return this.#queryCache.get(options.queryHash)?.state.data as
      | TInferredQueryFnData
      | undefined
```

While this works, using generics is a more type-safe and idiomatic approach in TypeScript. It allows the type system to infer the correct type for `TInferredQueryFnData` when `queryCache.get` is called, reducing the need for manual type casting and potential runtime errors if the cast is incorrect.

## Changes

The `getQueryData` method has been updated to pass `TInferredQueryFnData` as a generic type argument to `this.#queryCache.get()`:

**Before:**

```typescript
    return this.#queryCache.get(options.queryHash)?.state.data as
      | TInferredQueryFnData
      | undefined
```

**After:**

```typescript
    return this.#queryCache.get<TInferredQueryFnData>(options.queryHash)?.state
      .data
```

This change leverages the existing generic type parameter `TInferredQueryFnData` already defined in the `getQueryData` signature and `QueryCache#get` method.
2025-06-02 18:49:16 +02:00
MINSEONG KIM
3e7d715718
feat(query-devtools): add indicator for staleTime: "static" (#9215)
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-06-02 18:46:15 +02:00
Tanner Linsley
214fafdae5 release: v5.79.2 v5.79.2 2025-06-02 16:29:10 +00:00
novice0840
0e083c626f
refactor(react-query): change the order of const variables (#9211) 2025-06-02 18:22:22 +02:00
Braden Wong
0cbfc5ec6b
refactor(query-core): extract context creation to functions and move type assertions (#9210)
This refactor extracts the creation of the query function context and fetch context into dedicated helper functions (e.g., `createQueryFnContext`), improving code readability. This change:

- Moves type assertions and type handling higher up, reducing inline type noise and making type boundaries clearer.
- Replaces ad-hoc object construction with a function that does one thing (build query contexts).

No functional behavior is changed; this is a structural and type-safety improvement.
2025-06-02 18:21:31 +02:00
Tanner Linsley
7c5a8b6b96 release: v5.79.1 v5.79.1 2025-06-02 16:17:53 +00:00
Zentrik
ff2b51a7da
docs: Mention query keys needs to be serializable using JSON.stringify (#9204)
This was not clear to me and so maybe a useful addition to the docs
2025-06-02 18:11:06 +02:00
Braden Wong
982f6ca607
refactor(types): narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)
* refactor: narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void

Previously, the `onSuccess`, `onError`, `onMutate`, and `onSettled` callbacks were typed as `() => Promise<unknown> | unknown`. While `unknown` is technically valid, it implies that the return value might be used, assigned, or further processed. However, throughout the codebase, these callbacks are invoked solely for their side effects, and their return values are always ignored. Narrowing the type to `Promise<void> | void` makes this intent explicit, clarifies that any return value will be discarded, and prevents misleading type signatures that suggest otherwise.

This commit narrows their types to `() => Promise<void> | void`, which more accurately reflects their intended use.

* docs: update callback return types to Promise<void> | void in mutation-related documentation

This commit refines the documentation for mutation-related callbacks (`onSuccess`, `onError`, `onSettled`, and `onMutate`), changing their return types from `Promise<unknown> | unknown` to `Promise<void> | void`.
2025-06-02 18:09:24 +02:00
Tanner Linsley
7cf6ef515f release: v5.79.0 v5.79.0 2025-05-29 09:42:36 +00:00
Dominik Dorfmeister
b475d21568
feat(core): staleTime: 'static' (#9139)
* feat(core): StaleTime.Static

* fix: consider StaleTime.Static for invalidation

previously, it didn't matter if we included `stale: true` or not in the filters for refetch, because marking things with query.invalidate() would set them all to stale anyway.

Now, queries with StaleTime.Static will be marked as `invalidated`, but still shouldn't be refetched. The `isStale` filter logic accounts for that, so we have to include it in the filters

* fix: isStale order check

check for observers first because they contain the source of truth calculated with `isStaleByTime`, and it also takes enabled into account

* fix: isStaleByTime logic

we have to check for undefined data first, because queries without data are really always stale; then, the next check must be against StaleTime.Static, because queries that are marked as invalidated are still not stale, even if they are static.

* tests

* fix: type issue in react

* fix: make sure invalidation _always_ only refetches stale queries

this ensures we never refetch Static queries

* fix: never refetch static queries

* fix: make sure we don't refetchOn... for StaleTime.Static even when 'always' is set

* docs: StaleTime.Static

* ref: switch to 'static' string

* docs
2025-05-29 11:40:52 +02:00
Dominik Dorfmeister
34eedd601c
chore: update to eslint-plugin-react-hooks v6 (#9071)
* chore: update to eslint-plugin-react-hooks v6

and remove the separate compiler linter plugin, as those rules are now integrated

* chore: disable compiler-linter in tests

* chore: bypass lint violations

* chore: Disable '@eslint-react/no-context-provider'

to be react 18 compatible
2025-05-29 11:09:26 +02:00
Arnoud
9e30aafa0b
chore(angular-query): update to angular 20 stable (#9209) 2025-05-28 21:12:03 +02:00
Tanner Linsley
7a6733f75b release: v5.78.0 v5.78.0 2025-05-26 13:28:10 +00:00
jochong
a1210cbf81
feat(eslint-plugin): refactor and add mutation-property-order rule (#9191)
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-05-26 15:18:56 +02:00
Tanner Linsley
f2aa150774 release: v5.77.2 v5.77.2 2025-05-26 12:08:18 +00:00
Jonghyeon Ko
b2af5689f3
refactor: centralize NonUndefinedGuard type definition (#9187)
Moved the NonUndefinedGuard type definition to the query-core package for better reusability across various query options files in angular, react, solid, svelte, and vue packages. Removed duplicate definitions from individual files.
2025-05-26 14:03:44 +02:00