Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/alpha' into serverInfinite
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLey committed Mar 19, 2022
2 parents 1d25e75 + 1b91f3f commit bc8be68
Show file tree
Hide file tree
Showing 198 changed files with 10,289 additions and 5,636 deletions.
14 changes: 5 additions & 9 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@ const loose = true
module.exports = {
presets: [
[
'@babel/env',
'@babel/preset-env',
{
loose,
modules: false,
exclude: ['@babel/plugin-transform-regenerator'],
exclude: [
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-parameters',
],
},
],
'@babel/preset-typescript',
'@babel/react',
],
plugins: [
[
'const-enum',
{
transform: 'constObject',
},
],
'babel-plugin-transform-async-to-promises',
cjs && ['@babel/transform-modules-commonjs', { loose }],
[
'@babel/transform-runtime',
Expand Down
12 changes: 5 additions & 7 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Browsers we support
> 0.5%
Chrome >= 73
ChromeAndroid >= 75
Firefox >= 67
Edge >= 17
IE 11
Safari >= 12.1
iOS >= 11.3
Firefox >= 78
Edge >= 79
Safari >= 12.0
iOS >= 12.0
opera >= 53
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"es6": true
},
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module"
},
"rules": {
Expand All @@ -21,6 +22,7 @@
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-inferrable-types": [
"error",
{
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- 'master'
- 'next'
- 'alpha'
- 'beta'
- '1.x'
- '2.x'
Expand Down Expand Up @@ -36,7 +37,7 @@ jobs:
name: 'Publish Module to NPM'
needs: test
# publish only when merged in master on original repo, not on PR
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')
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')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ If you have been assigned to fix an issue or develop a new feature, please follo

## Online one-click setup

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:
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:

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

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

## Commit message conventions

Expand Down
3 changes: 3 additions & 0 deletions codemods/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
testMatch: ['<rootDir>/**/*.test.js'],
}
94 changes: 94 additions & 0 deletions codemods/v4/__testfixtures__/default-import.input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import * as React from 'react'
import {
QueryCache,
QueryClient,
useInfiniteQuery,
useIsFetching,
useIsMutating,
useMutation,
useQueries,
useQuery,
useQueryClient,
} from 'react-query'

export const Examples = () => {
useQuery('todos')
useInfiniteQuery('todos')
useMutation('todos')
useIsFetching('todos')
useIsMutating('todos')
useQueries([query1, query2])
// QueryClient methods
// --- Instantiated hook call.
const queryClient = useQueryClient()
queryClient.getMutationDefaults('todos')
queryClient.getQueriesData('todos')
queryClient.getQueryData('todos')
queryClient.getQueryDefaults('todos')
queryClient.getQueryState('todos')
queryClient.isFetching('todos')
queryClient.setMutationDefaults('todos', { mutationFn: async () => null })
queryClient.setQueriesData('todos', () => null)
queryClient.setQueryData('todos', () => null)
queryClient.setQueryDefaults('todos', { queryFn: async () => null })
queryClient.cancelQueries('todos')
queryClient.fetchInfiniteQuery('todos')
queryClient.fetchQuery('todos')
queryClient.invalidateQueries('todos')
queryClient.prefetchInfiniteQuery('todos')
queryClient.prefetchQuery('todos')
queryClient.refetchQueries('todos')
queryClient.removeQueries('todos')
queryClient.resetQueries('todos')
// --- Direct hook call.
useQueryClient().getMutationDefaults('todos')
useQueryClient().getQueriesData('todos')
useQueryClient().getQueryData('todos')
useQueryClient().getQueryDefaults('todos')
useQueryClient().getQueryState('todos')
useQueryClient().isFetching('todos')
useQueryClient().setMutationDefaults('todos', {
mutationFn: async () => null,
})
useQueryClient().setQueriesData('todos', () => null)
useQueryClient().setQueryData('todos', () => null)
useQueryClient().setQueryDefaults('todos', { queryFn: async () => null })
useQueryClient().cancelQueries('todos')
useQueryClient().fetchInfiniteQuery('todos')
useQueryClient().fetchQuery('todos')
useQueryClient().invalidateQueries('todos')
useQueryClient().prefetchInfiniteQuery('todos')
useQueryClient().prefetchQuery('todos')
useQueryClient().refetchQueries('todos')
useQueryClient().removeQueries('todos')
useQueryClient().resetQueries('todos')
// QueryCache
// --- NewExpression
const queryCache1 = new QueryCache({
onError: (error) => console.log(error),
onSuccess: (success) => console.log(success)
})
queryCache1.find('todos')
queryCache1.findAll('todos')
// --- Instantiated hook call.
const queryClient1 = useQueryClient()
queryClient1.getQueryCache().find('todos')
queryClient1.getQueryCache().findAll('todos')
//
const queryClient2 = new QueryClient({})
queryClient2.getQueryCache().find('todos')
queryClient2.getQueryCache().findAll('todos')
//
const queryCache2 = queryClient1.getQueryCache()
queryCache2.find('todos')
queryCache2.findAll('todos')
// --- Direct hook call.
useQueryClient().getQueryCache().find('todos')
useQueryClient().getQueryCache().findAll('todos')
//
const queryCache3 = useQueryClient().getQueryCache()
queryCache3.find('todos')
queryCache3.findAll('todos')

return <div>Example Component</div>
}
96 changes: 96 additions & 0 deletions codemods/v4/__testfixtures__/default-import.output.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import * as React from 'react'
import {
QueryCache,
QueryClient,
useInfiniteQuery,
useIsFetching,
useIsMutating,
useMutation,
useQueries,
useQuery,
useQueryClient,
} from 'react-query'

export const Examples = () => {
useQuery(['todos'])
useInfiniteQuery(['todos'])
useMutation(['todos'])
useIsFetching(['todos'])
useIsMutating(['todos'])
useQueries({
queries: [query1, query2]
})
// QueryClient methods
// --- Instantiated hook call.
const queryClient = useQueryClient()
queryClient.getMutationDefaults(['todos'])
queryClient.getQueriesData(['todos'])
queryClient.getQueryData(['todos'])
queryClient.getQueryDefaults(['todos'])
queryClient.getQueryState(['todos'])
queryClient.isFetching(['todos'])
queryClient.setMutationDefaults(['todos'], { mutationFn: async () => null })
queryClient.setQueriesData(['todos'], () => null)
queryClient.setQueryData(['todos'], () => null)
queryClient.setQueryDefaults(['todos'], { queryFn: async () => null })
queryClient.cancelQueries(['todos'])
queryClient.fetchInfiniteQuery(['todos'])
queryClient.fetchQuery(['todos'])
queryClient.invalidateQueries(['todos'])
queryClient.prefetchInfiniteQuery(['todos'])
queryClient.prefetchQuery(['todos'])
queryClient.refetchQueries(['todos'])
queryClient.removeQueries(['todos'])
queryClient.resetQueries(['todos'])
// --- Direct hook call.
useQueryClient().getMutationDefaults(['todos'])
useQueryClient().getQueriesData(['todos'])
useQueryClient().getQueryData(['todos'])
useQueryClient().getQueryDefaults(['todos'])
useQueryClient().getQueryState(['todos'])
useQueryClient().isFetching(['todos'])
useQueryClient().setMutationDefaults(['todos'], {
mutationFn: async () => null,
})
useQueryClient().setQueriesData(['todos'], () => null)
useQueryClient().setQueryData(['todos'], () => null)
useQueryClient().setQueryDefaults(['todos'], { queryFn: async () => null })
useQueryClient().cancelQueries(['todos'])
useQueryClient().fetchInfiniteQuery(['todos'])
useQueryClient().fetchQuery(['todos'])
useQueryClient().invalidateQueries(['todos'])
useQueryClient().prefetchInfiniteQuery(['todos'])
useQueryClient().prefetchQuery(['todos'])
useQueryClient().refetchQueries(['todos'])
useQueryClient().removeQueries(['todos'])
useQueryClient().resetQueries(['todos'])
// QueryCache
// --- NewExpression
const queryCache1 = new QueryCache({
onError: (error) => console.log(error),
onSuccess: (success) => console.log(success)
})
queryCache1.find(['todos'])
queryCache1.findAll(['todos'])
// --- Instantiated hook call.
const queryClient1 = useQueryClient()
queryClient1.getQueryCache().find(['todos'])
queryClient1.getQueryCache().findAll(['todos'])
//
const queryClient2 = new QueryClient({})
queryClient2.getQueryCache().find(['todos'])
queryClient2.getQueryCache().findAll(['todos'])
//
const queryCache2 = queryClient1.getQueryCache()
queryCache2.find(['todos'])
queryCache2.findAll(['todos'])
// --- Direct hook call.
useQueryClient().getQueryCache().find(['todos'])
useQueryClient().getQueryCache().findAll(['todos'])
//
const queryCache3 = useQueryClient().getQueryCache()
queryCache3.find(['todos'])
queryCache3.findAll(['todos'])

return <div>Example Component</div>
}
96 changes: 96 additions & 0 deletions codemods/v4/__testfixtures__/named-import.input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import * as React from 'react'
import {
QueryCache as RenamedQueryCache,
QueryClient as RenamedQueryClient,
useInfiniteQuery as useRenamedInfiniteQuery,
useIsFetching as useRenamedIsFetching,
useIsMutating as useRenamedIsMutating,
useMutation as useRenamedMutation,
useQueries as useRenamedQueries,
useQuery as useRenamedQuery,
useQueryClient as useRenamedQueryClient,
} from 'react-query'

export const Examples = () => {
useRenamedQuery('todos')
useRenamedInfiniteQuery('todos')
useRenamedMutation('todos')
useRenamedIsFetching('todos')
useRenamedIsMutating('todos')
useRenamedQueries([query1, query2])
// QueryClient methods
// --- Instantiated hook call.
const queryClient = useRenamedQueryClient()
queryClient.getMutationDefaults('todos')
queryClient.getQueriesData('todos')
queryClient.getQueryData('todos')
queryClient.getQueryDefaults('todos')
queryClient.getQueryState('todos')
queryClient.isFetching('todos')
queryClient.setMutationDefaults('todos', { mutationFn: async () => null })
queryClient.setQueriesData('todos', () => null)
queryClient.setQueryData('todos', () => null)
queryClient.setQueryDefaults('todos', { queryFn: async () => null })
queryClient.cancelQueries('todos')
queryClient.fetchInfiniteQuery('todos')
queryClient.fetchQuery('todos')
queryClient.invalidateQueries('todos')
queryClient.prefetchInfiniteQuery('todos')
queryClient.prefetchQuery('todos')
queryClient.refetchQueries('todos')
queryClient.removeQueries('todos')
queryClient.resetQueries('todos')
// --- Direct hook call.
useRenamedQueryClient().getMutationDefaults('todos')
useRenamedQueryClient().getQueriesData('todos')
useRenamedQueryClient().getQueryData('todos')
useRenamedQueryClient().getQueryDefaults('todos')
useRenamedQueryClient().getQueryState('todos')
useRenamedQueryClient().isFetching('todos')
useRenamedQueryClient().setMutationDefaults('todos', {
mutationFn: async () => null,
})
useRenamedQueryClient().setQueriesData('todos', () => null)
useRenamedQueryClient().setQueryData('todos', () => null)
useRenamedQueryClient().setQueryDefaults('todos', {
queryFn: async () => null,
})
useRenamedQueryClient().cancelQueries('todos')
useRenamedQueryClient().fetchInfiniteQuery('todos')
useRenamedQueryClient().fetchQuery('todos')
useRenamedQueryClient().invalidateQueries('todos')
useRenamedQueryClient().prefetchInfiniteQuery('todos')
useRenamedQueryClient().prefetchQuery('todos')
useRenamedQueryClient().refetchQueries('todos')
useRenamedQueryClient().removeQueries('todos')
useRenamedQueryClient().resetQueries('todos')
// QueryCache
// --- NewExpression
const queryCache1 = new RenamedQueryCache({
onError: (error) => console.log(error),
onSuccess: (success) => console.log(success)
})
queryCache1.find('todos')
queryCache1.findAll('todos')
// --- Instantiated hook call.
const queryClient1 = useRenamedQueryClient()
queryClient1.getQueryCache().find('todos')
queryClient1.getQueryCache().findAll('todos')
//
const queryClient2 = new RenamedQueryClient({})
queryClient2.getQueryCache().find('todos')
queryClient2.getQueryCache().findAll('todos')
//
const queryCache2 = queryClient1.getQueryCache()
queryCache2.find('todos')
queryCache2.findAll('todos')
// --- Direct hook call.
useRenamedQueryClient().getQueryCache().find('todos')
useRenamedQueryClient().getQueryCache().findAll('todos')
//
const queryCache3 = useRenamedQueryClient().getQueryCache()
queryCache3.find('todos')
queryCache3.findAll('todos')

return <div>Example Component</div>
}
Loading

0 comments on commit bc8be68

Please sign in to comment.