Skip to content

Commit 56df0f7

Browse files
committed
Merge remote-tracking branch 'tanstack/alpha' into refactor/react-query-devtools-panels
2 parents afe564f + 633115a commit 56df0f7

45 files changed

Lines changed: 439 additions & 148 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-v3.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches:
66
- 'v3'
7+
env:
8+
NX_DAEMON: false
9+
NX_VERBOSE_LOGGING: true
10+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
711
jobs:
812
test:
913
name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}'

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ on:
1414
- 'alpha'
1515
- 'beta'
1616
env:
17-
NX_DAEMON: 'false'
17+
NX_DAEMON: false
18+
NX_VERBOSE_LOGGING: true
19+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
1820
jobs:
1921
test-and-publish:
2022
if: github.repository == 'TanStack/query' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta')
@@ -37,7 +39,7 @@ jobs:
3739
- name: Run Tests
3840
uses: nick-fields/[email protected]
3941
with:
40-
command: pnpm run test:ci
42+
command: pnpm run test:ci --base=${{ github.event.before }}
4143
timeout_minutes: 10
4244
max_attempts: 3
4345
- name: Publish

.github/workflows/pr.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
name: pr
22
on: [pull_request]
33
env:
4-
NX_DAEMON: 'false'
4+
NX_DAEMON: false
5+
NX_VERBOSE_LOGGING: true
6+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
57
jobs:
68
test:
79
name: 'Test'
810
runs-on: ubuntu-latest
911
steps:
1012
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
ref: ${{ github.head_ref }}
16+
repository: ${{github.event.pull_request.head.repo.full_name}}
1117
- uses: pnpm/[email protected]
1218
with:
1319
version: 7
@@ -20,7 +26,7 @@ jobs:
2026
- name: Run Tests
2127
uses: nick-fields/[email protected]
2228
with:
23-
command: pnpm test:lib
29+
command: pnpm test:lib --base=${{ github.event.pull_request.base.sha }}
2430
timeout_minutes: 5
2531
max_attempts: 3
2632
- name: Upload coverage to Codecov
@@ -30,6 +36,10 @@ jobs:
3036
runs-on: ubuntu-latest
3137
steps:
3238
- uses: actions/checkout@v3
39+
with:
40+
fetch-depth: 0
41+
ref: ${{ github.head_ref }}
42+
repository: ${{github.event.pull_request.head.repo.full_name}}
3343
- uses: pnpm/[email protected]
3444
with:
3545
version: 7
@@ -39,12 +49,16 @@ jobs:
3949
cache: 'pnpm'
4050
- name: Install dependencies
4151
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
42-
- run: pnpm run test:eslint
52+
- run: pnpm run test:eslint --base=${{ github.event.pull_request.base.sha }}
4353
typecheck:
4454
name: 'Typecheck'
4555
runs-on: ubuntu-latest
4656
steps:
4757
- uses: actions/checkout@v3
58+
with:
59+
fetch-depth: 0
60+
ref: ${{ github.head_ref }}
61+
repository: ${{github.event.pull_request.head.repo.full_name}}
4862
- uses: pnpm/[email protected]
4963
with:
5064
version: 7
@@ -54,12 +68,16 @@ jobs:
5468
cache: 'pnpm'
5569
- name: Install dependencies
5670
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
57-
- run: pnpm run test:types
71+
- run: pnpm run test:types --base=${{ github.event.pull_request.base.sha }}
5872
format:
5973
name: 'Format'
6074
runs-on: ubuntu-latest
6175
steps:
6276
- uses: actions/checkout@v3
77+
with:
78+
fetch-depth: 0
79+
ref: ${{ github.head_ref }}
80+
repository: ${{github.event.pull_request.head.repo.full_name}}
6381
- uses: pnpm/[email protected]
6482
with:
6583
version: 7
@@ -69,7 +87,7 @@ jobs:
6987
cache: 'pnpm'
7088
- name: Install dependencies
7189
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
72-
- run: pnpm run test:format
90+
- run: pnpm run test:format --base=${{ github.event.pull_request.base.sha }}
7391
test-build:
7492
name: 'Test Build'
7593
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ node_modules
4343
.cache
4444
dist
4545
.idea
46+
47+
nx-cloud.env

docs/react/guides/migrating-to-v5.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ However, refetching all pages might lead to UI inconsistencies. Also, this optio
300300

301301
The v5 includes a new `maxPages` option for infinite queries to limit the number of pages to store in the query data and to refetch. This new feature handles the use cases initially identified for the `refetchPage` page feature without the related issues.
302302

303+
### New hydration API
304+
305+
The options you can pass to dehydrate have been simplified. Queries and Mutations are always dehydrated (according to the default function implementation). To change this behaviour, you can implement `shouldDehydrateQuery` or `shouldDehydrateMutation`.
306+
307+
```diff
308+
- dehydrateMutations?: boolean
309+
- dehydrateQueries?: boolean
310+
```
311+
303312
### Infinite queries now need a `defaultPageParam`
304313

305314
Previously, we've passed `undefined` to the `queryFn` as `pageParam`, and you could assign a default value to the `pageParam` parameter in the `queryFn` function signature. This had the drawback of storing `undefined` in the `queryCache`, which is not serializable.
@@ -410,7 +419,7 @@ We have a new, simplified way to perform optimistic updates by leveraging the re
410419

411420
Here, we are only changing how the UI looks when the mutation is running instead of writing data directly to the cache. This works best if we only have one place where we need to show the optimistic update. For more details, have a look at the [optimistic updates documentation](../guides/optimistic-updates.md).
412421

413-
### Eternal list: scalable infinite query with new maxPages option
422+
### Limited, Infinite Queries with new maxPages option
414423

415424
Infinite queries are great when infinite scroll or pagination are needed.
416425
However, the more pages you fetch, the more memory you consume, and this also slows down the query refetching process as all the pages are sequentially refetched.

docs/react/guides/paginated-queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This experience is not optimal and unfortunately is how many tools today insist
2424

2525
Consider the following example where we would ideally want to increment a pageIndex (or cursor) for a query. If we were to use `useQuery`, **it would still technically work fine**, but the UI would jump in and out of the `success` and `pending` states as different queries are created and destroyed for each page or cursor. By setting `placeholderData` to `(previousData) => previousData` or `keepPreviousData` function exported from TanStack Query, we get a few new things:
2626

27-
- **The data from the last successful fetch available while new data is being requested, even though the query key has changed**.
27+
- **The data from the last successful fetch is available while new data is being requested, even though the query key has changed**.
2828
- When the new data arrives, the previous `data` is seamlessly swapped to show the new data.
2929
- `isPlaceholderData` is made available to know what data the query is currently providing you
3030

docs/react/reference/hydration.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { dehydrate } from '@tanstack/react-query'
1212

1313
const dehydratedState = dehydrate(queryClient, {
1414
shouldDehydrateQuery,
15+
shouldDehydrateMutation,
1516
})
1617
```
1718

@@ -22,24 +23,20 @@ const dehydratedState = dehydrate(queryClient, {
2223
- The `queryClient` that should be dehydrated
2324
- `options: DehydrateOptions`
2425
- Optional
25-
- `dehydrateMutations: boolean`
26-
- Optional
27-
- Whether or not to dehydrate mutations.
28-
- `dehydrateQueries: boolean`
29-
- Optional
30-
- Whether or not to dehydrate queries.
3126
- `shouldDehydrateMutation: (mutation: Mutation) => boolean`
3227
- Optional
33-
- This function is called for each mutation in the cache
34-
- Return `true` to include this mutation in dehydration, or `false` otherwise
35-
- The default version only includes paused mutations
36-
- If you would like to extend the function while retaining the previous behavior, import and execute `defaultShouldDehydrateMutation` as part of the return statement
37-
- `shouldDehydrateQuery: (query: Query) => boolean`
28+
- Whether to dehydrate mutations.
29+
- The function is called for each mutation in the cache
30+
- Return `true` to include this mutation in dehydration, or `false` otherwise
31+
- Defaults to only including paused mutations
32+
- If you would like to extend the function while retaining the default behavior, import and execute `defaultShouldDehydrateMutation` as part of the return statement
33+
- `shouldDehydrateQuery: boolean | (query: Query) => boolean`
3834
- Optional
39-
- This function is called for each query in the cache
40-
- Return `true` to include this query in dehydration, or `false` otherwise
41-
- The default version only includes successful queries, do `shouldDehydrateQuery: () => true` to include all queries
42-
- If you would like to extend the function while retaining the previous behavior, import and execute `defaultShouldDehydrateQuery` as part of the return statement
35+
- Whether to dehydrate queries.
36+
- The function, it is called for each query in the cache
37+
- Return `true` to include this query in dehydration, or `false` otherwise
38+
- Defaults to only including successful queries
39+
- If you would like to extend the function while retaining the default behavior, import and execute `defaultShouldDehydrateQuery` as part of the return statement
4340

4441
**Returns**
4542

docs/react/reference/useQueries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ The `useQueries` hook accepts an options object with a **queries** key whose val
2525
2626
**Returns**
2727

28-
The `useQueries` hook returns an array with all the query results.
28+
The `useQueries` hook returns an array with all the query results. The order returned is the same as the input order.

nx.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"tasksRunnerOptions": {
33
"default": {
4-
"runner": "nx/tasks-runners/default",
4+
"runner": "@nrwl/nx-cloud",
55
"options": {
66
"cacheableOperations": [
77
"test:lib",
88
"test:eslint",
99
"test:types",
1010
"build:types",
11-
"test:format",
12-
"test:build",
13-
"build"
14-
]
11+
"build",
12+
"rollup"
13+
],
14+
"accessToken": "ZDdkNDA4MGEtYjNmYi00MWI4LWE1N2QtYTdlNmYxMGJlZWM2fHJlYWQ="
1515
}
1616
}
1717
},
@@ -52,12 +52,18 @@
5252
"inputs": ["default", "^public"]
5353
},
5454
"test:types": {
55-
"outputs": ["{projectRoot}/build"],
55+
"outputs": [
56+
"{projectRoot}/build/**/*.d.ts",
57+
"{projectRoot}/build/.tsbuildinfo"
58+
],
5659
"inputs": ["default", "^public"],
5760
"dependsOn": ["^test:types"]
5861
},
5962
"build:types": {
60-
"outputs": ["{projectRoot}/build"],
63+
"outputs": [
64+
"{projectRoot}/build/**/*.d.ts",
65+
"{projectRoot}/build/.tsbuildinfo"
66+
],
6167
"inputs": ["default", "^public"],
6268
"dependsOn": ["^build:types"]
6369
},

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
"preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...'); process.exit(1)}\" || npx -y only-allow pnpm",
77
"install:csb": "pnpm install --frozen-lockfile",
88
"test": "pnpm run test:ci",
9-
"test:ci": "nx run-many --targets=test:lib,test:types,test:eslint,test:format --parallel=5",
10-
"test:eslint": "nx run-many --target=test:eslint --parallel=5",
11-
"test:format": "nx test:format root",
12-
"test:lib": "nx run-many --target=test:lib --parallel=5",
9+
"test:ci": "nx affected --targets=test:lib,test:types,test:eslint,test:format --parallel=5",
10+
"test:eslint": "nx affected --target=test:eslint --parallel=5",
11+
"test:format": "pnpm run prettier --check",
12+
"test:lib": "nx affected --target=test:lib --parallel=5",
1313
"test:lib:dev": "pnpm --filter \"./packages/**\" run test:lib:dev",
14-
"test:build": "nx test:build root",
15-
"test:types": "nx run-many --target=test:types --parallel=5",
16-
"build": "nx build root",
17-
"build:types": "nx run-many --target=build:types --parallel=5",
14+
"test:build": "nx run-many --target=test:build --projects=root",
15+
"test:types": "nx affected --target=test:types --parallel=5",
16+
"build": "nx run-many --target=build --projects=root",
17+
"build:types": "nx affected --target=build:types --parallel=5",
1818
"watch": "concurrently --kill-others \"rollup --config rollup.config.js -w\" \"pnpm run build:types --watch\"",
1919
"dev": "pnpm run watch",
2020
"prettier": "prettier --plugin-search-dir . \"{packages,examples}/**/src/**/*.{md,js,jsx,ts,tsx,json,vue,svelte}\"",
@@ -35,7 +35,7 @@
3535
"@babel/preset-react": "^7.18.6",
3636
"@babel/preset-typescript": "^7.18.6",
3737
"@commitlint/parse": "^17.4.2",
38-
"@faker-js/faker": "^7.6.0",
38+
"@nrwl/nx-cloud": "^15.3.1",
3939
"@rollup/plugin-babel": "^6.0.3",
4040
"@rollup/plugin-commonjs": "24.0.1",
4141
"@rollup/plugin-node-resolve": "^15.0.1",
@@ -56,7 +56,6 @@
5656
"@vitest/coverage-istanbul": "^0.27.1",
5757
"axios": "^1.3.2",
5858
"babel-eslint": "^10.1.0",
59-
"babel-plugin-transform-async-to-promises": "^0.8.18",
6059
"babel-preset-solid": "^1.6.10",
6160
"bundlewatch": "^0.3.3",
6261
"chalk": "^4.1.2",
@@ -87,6 +86,7 @@
8786
"react-dom": "^18.2.0",
8887
"rimraf": "^4.1.2",
8988
"rollup": "^3.15.0",
89+
"rollup-plugin-preserve-directives": "0.1.0",
9090
"rollup-plugin-size": "^0.2.2",
9191
"rollup-plugin-terser": "^7.0.2",
9292
"rollup-plugin-visualizer": "^5.9.0",

0 commit comments

Comments
 (0)