Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo authored Jan 3, 2025
2 parents 33909fb + bc8b9e7 commit e9b6f96
Show file tree
Hide file tree
Showing 79 changed files with 323 additions and 272 deletions.
11 changes: 3 additions & 8 deletions docs/framework/angular/guides/invalidations-from-mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ replace: { 'useMutation': 'injectMutation', 'hook': 'function' }
[//]: # 'Example'

```ts
class TodoItemComponent {
mutation = injectMutation(() => ({
mutationFn: postTodo,
}))
}
mutation = injectMutation(() => ({
mutationFn: postTodo,
}))
```

[//]: # 'Example'
Expand All @@ -33,9 +31,6 @@ export class TodosComponent {
onSuccess: () => {
this.queryClient.invalidateQueries({ queryKey: ['todos'] })
this.queryClient.invalidateQueries({ queryKey: ['reminders'] })

// OR use the queryClient that is injected into the component
// this.queryClient.invalidateQueries({ queryKey: ['todos'] })
},
}))
}
Expand Down
27 changes: 27 additions & 0 deletions docs/framework/react/guides/migrating-to-v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,33 @@ This last change is technically a breaking one, and was made so we don't prematu
+ </HydrationBoundary> // [!code ++]
```

### Query defaults changes

`queryClient.getQueryDefaults` will now merge together all matching registrations instead of returning only the first matching registration.

As a result, calls to `queryClient.setQueryDefaults` should now be ordered with _increasing_ specificity.
That is, registrations should be made from the **most generic key** to the **least generic one**.

For example:

```ts
+ queryClient.setQueryDefaults(['todo'], { // [!code ++]
+ retry: false, // [!code ++]
+ staleTime: 60_000, // [!code ++]
+ }) // [!code ++]
queryClient.setQueryDefaults(['todo', 'detail'], {
+ retry: true, // [!code --]
retryDelay: 1_000,
staleTime: 10_000,
})
- queryClient.setQueryDefaults(['todo'], { // [!code --]
- retry: false, // [!code --]
- staleTime: 60_000, // [!code --]
- }) // [!code --]
```

Note that in this specific example, `retry: true` was added to the `['todo', 'detail']` registration to counteract it now inheriting `retry: false` from the more general registration. The specific changes needed to maintain exact behavior will vary depending on your defaults.

[//]: # 'FrameworkSpecificBreakingChanges'

## New Features 🚀
Expand Down
7 changes: 4 additions & 3 deletions docs/reference/QueryClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ The `getQueryDefaults` method returns the default options which have been set fo
const defaultOptions = queryClient.getQueryDefaults(['posts'])
```

> Note that if several query defaults match the given query key, the **first** matching one is returned.
> This could lead to unexpected behaviours. See [`setQueryDefaults`](#queryclientsetquerydefaults).
> Note that if several query defaults match the given query key, they will be merged together based on the order of registration.
> See [`setQueryDefaults`](#queryclientsetquerydefaults).
## `queryClient.setQueryDefaults`

Expand All @@ -543,7 +543,8 @@ function Component() {
- `options: QueryOptions`

> As stated in [`getQueryDefaults`](#queryclientgetquerydefaults), the order of registration of query defaults does matter.
> Since the **first** matching defaults are returned by `getQueryDefaults`, the registration should be made in the following order: from the **least generic key** to the **most generic one**. This way, in case of specific key, the first matching one would be the expected one.
> Since the matching defaults are merged by `getQueryDefaults`, the registration should be made in the following order: from the **most generic key** to the **least generic one** .
> This way, more specific defaults will override more generic defaults.
## `queryClient.getMutationDefaults`

Expand Down
2 changes: 1 addition & 1 deletion examples/angular/auto-refetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@angular/core": "^19.1.0-next.0",
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@angular/core": "^19.1.0-next.0",
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/devtools-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@angular/router": "^19.1.0-next.0",
"@tanstack/angular-query-devtools-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-devtools-experimental": "^5.62.13",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@angular/core": "^19.1.0-next.0",
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@angular/core": "^19.1.0-next.0",
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/query-options-from-a-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@angular/router": "^19.1.0-next.0",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@angular/router": "^19.1.0-next.0",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/rxjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@angular/forms": "19.1.0-next.0",
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@angular/core": "^19.1.0-next.0",
"@angular/platform-browser": "^19.1.0-next.0",
"@angular/platform-browser-dynamic": "^19.1.0-next.0",
"@tanstack/angular-query-experimental": "^5.62.9",
"@tanstack/angular-query-experimental": "^5.62.13",
"rxjs": "^7.8.1",
"tslib": "^2.6.3",
"zone.js": "^0.15.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"dependencies": {
"@algolia/client-search": "5.2.1",
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/auto-refetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic-graphql-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"graphql": "^16.9.0",
"graphql-request": "^7.1.2",
"react": "^19.0.0",
Expand Down
8 changes: 4 additions & 4 deletions examples/react/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/query-sync-storage-persister": "^5.62.9",
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query-persist-client": "^5.62.11",
"@tanstack/query-sync-storage-persister": "^5.62.12",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"@tanstack/react-query-persist-client": "^5.62.12",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/default-query-function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/devtools-panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/infinite-query-with-max-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/load-more-infinite-scroll/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/nextjs-app-prefetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^15.1.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
Expand Down
6 changes: 3 additions & 3 deletions examples/react/nextjs-suspense-streaming/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query-next-experimental": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"@tanstack/react-query-next-experimental": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
8 changes: 4 additions & 4 deletions examples/react/offline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/query-sync-storage-persister": "^5.62.9",
"@tanstack/query-sync-storage-persister": "^5.62.12",
"@tanstack/react-location": "^3.7.4",
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query-persist-client": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"@tanstack/react-query-persist-client": "^5.62.12",
"msw": "^2.6.6",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/optimistic-updates-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/optimistic-updates-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/prefetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"start": "next start"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"next": "^14.2.20",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"@react-native-community/netinfo": "^11.4.1",
"@react-navigation/native": "^6.1.18",
"@react-navigation/stack": "^6.4.1",
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"expo": "^52.0.11",
"expo-constants": "^17.0.3",
"expo-status-bar": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test:types": "tsc"
},
"dependencies": {
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"localforage": "^1.10.0",
"match-sorter": "^6.3.4",
"react": "^19.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/rick-morty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@emotion/styled": "^11.13.5",
"@mui/material": "^6.1.8",
"@mui/styles": "^6.1.8",
"@tanstack/react-query": "^5.62.11",
"@tanstack/react-query-devtools": "^5.62.11",
"@tanstack/react-query": "^5.62.12",
"@tanstack/react-query-devtools": "^5.62.12",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router": "^6.25.1",
Expand Down
Loading

0 comments on commit e9b6f96

Please sign in to comment.