Skip to content

Commit b265c44

Browse files
author
Guillaume Labat
committed
Merge branch 'beta' of https://github.com/TanStack/query into TanStack-beta
* 'beta' of https://github.com/TanStack/query: (140 commits) Fix Best of JS badge in README (TanStack#3695) Update config.json docs: adapter teasers docs: rewrite typescript docs tests: stabilize docs: Update graphql.md to fix link (TanStack#3683) docs: fix link typo in README.md (TanStack#3679) Update README.md update readme Update config.json Update index.js examples: vendor to platform directories docs: migrate to tanstack.com fix(persist): introduce in-house synchronous Storage interface (TanStack#3673) docs: restructure migration guide by importance of breaking changes fix: `replaceDeepEqual` special case for non-plain arrays (TanStack#3669) feat: make InfiniteQueryObserver's type more robust (TanStack#3571) fix(types): remove non-void constraint from queryFn result (TanStack#3666) fix(persist): remove environment check (TanStack#3658) fix(types): make sure queryClient.setQueriesData can return undefined from the updater (TanStack#3657) ...
2 parents 438d8fe + e61a623 commit b265c44

File tree

598 files changed

+17543
-24446
lines changed

Some content is hidden

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

598 files changed

+17543
-24446
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@
203203
"code",
204204
"doc"
205205
]
206+
},
207+
{
208+
"login": "zrwsk",
209+
"name": "Jakub Żurawski",
210+
"avatar_url": "https://avatars.githubusercontent.com/u/9089600?v=4",
211+
"profile": "https://github.com/zrwsk",
212+
"contributions": [
213+
"doc"
214+
]
206215
}
207216
],
208217
"contributorsPerLine": 7,

.babelrc.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
const { NODE_ENV, BABEL_ENV } = process.env
22
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
3+
const es = BABEL_ENV === 'es'
34
const loose = true
45

56
module.exports = {
67
presets: [
78
[
8-
'@babel/env',
9+
'@babel/preset-env',
910
{
1011
loose,
1112
modules: false,
12-
exclude: ['@babel/plugin-transform-regenerator'],
13+
exclude: [
14+
'@babel/plugin-transform-regenerator',
15+
'@babel/plugin-transform-parameters',
16+
],
1317
},
1418
],
1519
'@babel/preset-typescript',
1620
'@babel/react',
1721
],
1822
plugins: [
19-
[
20-
'const-enum',
21-
{
22-
transform: 'constObject',
23-
},
24-
],
25-
'babel-plugin-transform-async-to-promises',
2623
cjs && ['@babel/transform-modules-commonjs', { loose }],
27-
[
24+
es && ['babel-plugin-add-import-extension', { extension: 'mjs' }],
25+
// no runtime for umd builds
26+
BABEL_ENV && [
2827
'@babel/transform-runtime',
2928
{
30-
useESModules: !cjs,
3129
version: require('./package.json').dependencies[
3230
'@babel/runtime'
3331
].replace(/^[^0-9]*/, ''),

.browserslistrc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Browsers we support
2-
> 0.5%
32
Chrome >= 73
4-
ChromeAndroid >= 75
5-
Firefox >= 67
6-
Edge >= 17
7-
IE 11
8-
Safari >= 12.1
9-
iOS >= 11.3
3+
Firefox >= 78
4+
Edge >= 79
5+
Safari >= 12.0
6+
iOS >= 12.0
7+
opera >= 53

.eslintrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212
"es6": true
1313
},
1414
"parserOptions": {
15+
"project": "./tsconfig.json",
1516
"sourceType": "module"
1617
},
1718
"rules": {
19+
"react/jsx-key": ["error", { "checkFragmentShorthand": true }],
1820
"@typescript-eslint/ban-types": "off",
1921
"@typescript-eslint/ban-ts-comment": "off",
2022
"@typescript-eslint/explicit-module-boundary-types": "off",
2123
"@typescript-eslint/no-empty-interface": "off",
2224
"@typescript-eslint/no-explicit-any": "off",
2325
"@typescript-eslint/no-non-null-assertion": "off",
26+
"@typescript-eslint/no-unnecessary-condition": "error",
2427
"@typescript-eslint/no-inferrable-types": [
2528
"error",
2629
{
@@ -31,6 +34,19 @@
3134
"import/no-cycle": "error",
3235
"import/no-unresolved": ["error", { "ignore": ["react-query"] }],
3336
"import/no-unused-modules": ["off", { "unusedExports": true }],
37+
"import/no-restricted-paths": [
38+
"error",
39+
{
40+
"zones": [
41+
{ "target": "src/core", "from": "src/broadcastQueryClient-experimental" },
42+
{ "target": "src/core", "from": "src/createAsyncStoragePersister" },
43+
{ "target": "src/core", "from": "src/createWebStoragePersister" },
44+
{ "target": "src/core", "from": "src/devtools" },
45+
{ "target": "src/core", "from": "src/persistQueryClient" },
46+
{ "target": "src/core", "from": "src/reactjs" }
47+
]
48+
}
49+
],
3450
"no-redeclare": "off"
3551
}
3652
}

.github/workflows/test-and-publish.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ on:
55
branches:
66
- 'master'
77
- 'next'
8+
- 'alpha'
89
- 'beta'
910
- '1.x'
1011
- '2.x'
1112
pull_request:
1213

1314
jobs:
1415
test:
15-
name: 'Node ${{ matrix.node }}'
16+
name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}'
1617
runs-on: ubuntu-latest
1718
strategy:
1819
matrix:
19-
node: [12, 14, 16]
20+
node: [14, 16]
21+
react: [17, 18]
2022
steps:
2123
- uses: actions/checkout@v2
2224
- uses: actions/setup-node@v2
@@ -25,8 +27,10 @@ jobs:
2527
- name: Install dependencies
2628
uses: bahmutov/npm-install@v1
2729
- run: yarn test:ci
30+
env:
31+
REACTJS_VERSION: ${{ matrix.react }}
2832
- run: yarn test:size
29-
if: matrix.node == '16'
33+
if: matrix.node == '16' && matrix.react == '18'
3034
env:
3135
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
3236
- name: Upload coverage to Codecov
@@ -36,7 +40,7 @@ jobs:
3640
name: 'Publish Module to NPM'
3741
needs: test
3842
# publish only when merged in master on original repo, not on PR
39-
if: github.repository == 'tannerlinsley/react-query' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x')
43+
if: github.repository == 'tannerlinsley/react-query' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x')
4044
runs-on: ubuntu-latest
4145
steps:
4246
- uses: actions/checkout@v2

.vscode/settings.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
## Questions
44

5-
If you have questions about implementation details, help or support, then please use our dedicated community forum at [Github Discussions](https://github.com/tannerlinsley/react-query/discussions) **PLEASE NOTE:** If you choose to instead open an issue for your question, your issue will be immediately closed and redirected to the forum.
5+
If you have questions about implementation details, help or support, then please use our dedicated community forum at [GitHub Discussions](https://github.com/tannerlinsley/react-query/discussions) **PLEASE NOTE:** If you choose to instead open an issue for your question, your issue will be immediately closed and redirected to the forum.
66

77
## Reporting Issues
88

9-
If you have found what you think is a bug, please [file an issue](https://github.com/tannerlinsley/react-query/issues/new). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues will be immediately closed and redirected to [Github Discussions](https://github.com/tannerlinsley/react-query/discussions)
9+
If you have found what you think is a bug, please [file an issue](https://github.com/tannerlinsley/react-query/issues/new). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues will be immediately closed and redirected to [GitHub Discussions](https://github.com/tannerlinsley/react-query/discussions)
1010

1111
## Suggesting new features
1212

@@ -29,14 +29,14 @@ If you have been assigned to fix an issue or develop a new feature, please follo
2929

3030
## Online one-click setup
3131

32-
You can use Gitpod(An Online Open Source VS Code like IDE which is free for Open Source) for developing online. With a single click it will start a workspace and automatically:
32+
You can use Gitpod (An Online Open Source VS Code like IDE which is free for Open Source) for developing online. With a single click it will start a workspace and automatically:
3333

3434
- clone the `react-query` repo.
3535
- install all the dependencies in `/` and `/docs`.
3636
- run `yarn start` in the root(`/`) to Auto-build files.
3737
- run `yarn dev` in `/docs`.
3838

39-
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/from-referrer/)
39+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/tannerlinsley/react-query)
4040

4141
## Commit message conventions
4242

@@ -122,4 +122,4 @@ Use an appropriate commit type. Be especially careful with breaking changes.
122122

123123
## Releases
124124

125-
For each new commit added to `master` with `git push` or by merging a pull request or merging from another branch, a github action is triggered and runs the `semantic-release` command to make a release if there are codebase changes since the last release that affect the package functionalities.
125+
For each new commit added to `master` with `git push` or by merging a pull request or merging from another branch, a GitHub action is triggered and runs the `semantic-release` command to make a release if there are codebase changes since the last release that affect the package functionalities.

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="https://static.scarf.sh/a.png?x-pxid=be2d8a11-9712-4c1d-9963-580b2d4fb133" />
22

3-
![React Query Header](https://github.com/tannerlinsley/react-query/raw/master/media/repo-dark.png)
3+
![React Query Header](https://github.com/tannerlinsley/react-query/raw/beta/media/repo-header.png)
44

55
Hooks for fetching, caching and updating asynchronous data in React
66

@@ -18,7 +18,7 @@ Hooks for fetching, caching and updating asynchronous data in React
1818
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
1919
</a><a href="https://github.com/tannerlinsley/react-query/discussions">
2020
<img alt="Join the discussion on Github" src="https://img.shields.io/badge/Github%20Discussions%20%26%20Support-Chat%20now!-blue" />
21-
</a><a href="https://bestofjs.org/projects/react-query"><img alt="Best of JS" src="https://img.shields.io/endpoint?url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=tannerlinsley%2Freact-query%26since=daily" /></a><a href="https://github.com/tannerlinsley/react-query" target="\_parent">
21+
</a><a href="https://bestofjs.org/projects/react-query"><img alt="Best of JS" src="https://img.shields.io/endpoint?url=https://bestofjs-serverless.now.sh/api/project-badge?fullName=TanStack%2Fquery%26since=daily" /></a><a href="https://github.com/tannerlinsley/react-query" target="\_parent">
2222
<img alt="" src="https://img.shields.io/github/stars/tannerlinsley/react-query.svg?style=social&label=Star" />
2323
</a><a href="https://twitter.com/tannerlinsley" target="\_parent">
2424
<img alt="" src="https://img.shields.io/twitter/follow/tannerlinsley.svg?style=social&label=Follow" />
@@ -28,9 +28,10 @@ Hooks for fetching, caching and updating asynchronous data in React
2828

2929
Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Table](https://github.com/tannerlinsley/react-table), [React Form](https://github.com/tannerlinsley/react-form), [React Charts](https://github.com/tannerlinsley/react-charts)
3030

31-
## Visit [react-query.tanstack.com](https://react-query.tanstack.com) for docs, guides, API and more!
31+
## Visit [tanstack.com/query](https://tanstack.com/query) for docs, guides, API and more!
3232

33-
Still on **React Query v2**? No problem! Check out the v2 docs here: https://react-query-v2.tanstack.com/.
33+
Still on **React Query v2**? No problem! Check out the v2 docs here: https://react-query-v2.tanstack.com/. <br />
34+
Would you like to try **React Query v4beta**? Check out the v4 beta docs here: https://react-query-beta.tanstack.com/.
3435
## Quick Features
3536

3637
- Transport/protocol/backend agnostic data fetching (REST, GraphQL, promises, whatever!)
@@ -82,6 +83,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
8283
<td align="center"><a href="https://github.com/babycourageous"><img src="https://avatars.githubusercontent.com/u/14936212?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rene Dellefont</b></sub></a><br /><a href="https://github.com/tannerlinsley/react-query/commits?author=babycourageous" title="Code">💻</a> <a href="https://github.com/tannerlinsley/react-query/commits?author=babycourageous" title="Documentation">📖</a></td>
8384
<td align="center"><a href="https://github.com/jvuoti"><img src="https://avatars.githubusercontent.com/u/3702781?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Janne Vuoti</b></sub></a><br /><a href="https://github.com/tannerlinsley/react-query/commits?author=jvuoti" title="Code">💻</a></td>
8485
<td align="center"><a href="http://seaviewlab.com"><img src="https://avatars.githubusercontent.com/u/20332397?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Arnaud</b></sub></a><br /><a href="https://github.com/tannerlinsley/react-query/commits?author=arnaudbzn" title="Code">💻</a> <a href="https://github.com/tannerlinsley/react-query/commits?author=arnaudbzn" title="Documentation">📖</a></td>
86+
<td align="center"><a href="https://github.com/zrwsk"><img src="https://avatars.githubusercontent.com/u/9089600?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jakub Żurawski</b></sub></a><br /><a href="https://github.com/tannerlinsley/react-query/commits?author=zrwsk" title="Documentation">📖</a></td>
8587
</tr>
8688
</table>
8789

@@ -92,4 +94,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
9294

9395
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
9496

95-
<!-- Force 3 -->
97+
<!-- Force 4 -->
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../lib/broadcastQueryClient-experimental'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../lib/broadcastQueryClient-experimental/index')

codemods/jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
testMatch: ['<rootDir>/**/*.test.js'],
3+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import * as React from 'react'
2+
import {
3+
QueryCache,
4+
QueryClient,
5+
useInfiniteQuery,
6+
useIsFetching,
7+
useIsMutating,
8+
useMutation,
9+
useQueries,
10+
useQuery,
11+
useQueryClient,
12+
} from 'react-query'
13+
14+
export const Examples = () => {
15+
useQuery('todos')
16+
useInfiniteQuery('todos')
17+
useMutation('todos')
18+
useIsFetching('todos')
19+
useIsMutating('todos')
20+
useQueries([query1, query2])
21+
// QueryClient methods
22+
// --- Instantiated hook call.
23+
const queryClient = useQueryClient()
24+
queryClient.getMutationDefaults('todos')
25+
queryClient.getQueriesData('todos')
26+
queryClient.getQueryData('todos')
27+
queryClient.getQueryDefaults('todos')
28+
queryClient.getQueryState('todos')
29+
queryClient.isFetching('todos')
30+
queryClient.setMutationDefaults('todos', { mutationFn: async () => null })
31+
queryClient.setQueriesData('todos', () => null)
32+
queryClient.setQueryData('todos', () => null)
33+
queryClient.setQueryDefaults('todos', { queryFn: async () => null })
34+
queryClient.cancelQueries('todos')
35+
queryClient.fetchInfiniteQuery('todos')
36+
queryClient.fetchQuery('todos')
37+
queryClient.invalidateQueries('todos')
38+
queryClient.prefetchInfiniteQuery('todos')
39+
queryClient.prefetchQuery('todos')
40+
queryClient.refetchQueries('todos')
41+
queryClient.removeQueries('todos')
42+
queryClient.resetQueries('todos')
43+
// --- Direct hook call.
44+
useQueryClient().getMutationDefaults('todos')
45+
useQueryClient().getQueriesData('todos')
46+
useQueryClient().getQueryData('todos')
47+
useQueryClient().getQueryDefaults('todos')
48+
useQueryClient().getQueryState('todos')
49+
useQueryClient().isFetching('todos')
50+
useQueryClient().setMutationDefaults('todos', {
51+
mutationFn: async () => null,
52+
})
53+
useQueryClient().setQueriesData('todos', () => null)
54+
useQueryClient().setQueryData('todos', () => null)
55+
useQueryClient().setQueryDefaults('todos', { queryFn: async () => null })
56+
useQueryClient().cancelQueries('todos')
57+
useQueryClient().fetchInfiniteQuery('todos')
58+
useQueryClient().fetchQuery('todos')
59+
useQueryClient().invalidateQueries('todos')
60+
useQueryClient().prefetchInfiniteQuery('todos')
61+
useQueryClient().prefetchQuery('todos')
62+
useQueryClient().refetchQueries('todos')
63+
useQueryClient().removeQueries('todos')
64+
useQueryClient().resetQueries('todos')
65+
// QueryCache
66+
// --- NewExpression
67+
const queryCache1 = new QueryCache({
68+
onError: (error) => console.log(error),
69+
onSuccess: (success) => console.log(success)
70+
})
71+
queryCache1.find('todos')
72+
queryCache1.findAll('todos')
73+
// --- Instantiated hook call.
74+
const queryClient1 = useQueryClient()
75+
queryClient1.getQueryCache().find('todos')
76+
queryClient1.getQueryCache().findAll('todos')
77+
//
78+
const queryClient2 = new QueryClient({})
79+
queryClient2.getQueryCache().find('todos')
80+
queryClient2.getQueryCache().findAll('todos')
81+
//
82+
const queryCache2 = queryClient1.getQueryCache()
83+
queryCache2.find('todos')
84+
queryCache2.findAll('todos')
85+
// --- Direct hook call.
86+
useQueryClient().getQueryCache().find('todos')
87+
useQueryClient().getQueryCache().findAll('todos')
88+
//
89+
const queryCache3 = useQueryClient().getQueryCache()
90+
queryCache3.find('todos')
91+
queryCache3.findAll('todos')
92+
93+
return <div>Example Component</div>
94+
}

0 commit comments

Comments
 (0)