@tanstack/react-query 5.0.0-alpha.7 → 5.0.0-alpha.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/codemods/__testfixtures__/default-import.input.tsx +94 -0
- package/build/codemods/__testfixtures__/default-import.output.tsx +96 -0
- package/build/codemods/__testfixtures__/named-import.input.tsx +96 -0
- package/build/codemods/__testfixtures__/named-import.output.tsx +98 -0
- package/build/codemods/__testfixtures__/namespaced-import.input.tsx +86 -0
- package/build/codemods/__testfixtures__/namespaced-import.output.tsx +88 -0
- package/build/codemods/__testfixtures__/parameter-is-identifier.input.tsx +49 -0
- package/build/codemods/__testfixtures__/parameter-is-identifier.output.tsx +49 -0
- package/build/codemods/__testfixtures__/parameter-is-object-expression.input.tsx +128 -0
- package/build/codemods/__testfixtures__/parameter-is-object-expression.output.tsx +175 -0
- package/build/codemods/__testfixtures__/replace-import-specifier.input.tsx +10 -0
- package/build/codemods/__testfixtures__/replace-import-specifier.output.tsx +10 -0
- package/build/codemods/__testfixtures__/type-arguments.input.tsx +25 -0
- package/build/codemods/__testfixtures__/type-arguments.output.tsx +31 -0
- package/build/codemods/__tests__/key-transformation.test.js +32 -0
- package/build/codemods/__tests__/replace-import-specifier.test.js +12 -0
- package/build/codemods/remove-overloads/__testfixtures__/default-import.input.tsx +199 -0
- package/build/codemods/remove-overloads/__testfixtures__/default-import.output.tsx +484 -0
- package/build/codemods/remove-overloads/__tests__/remove-overloads.test.js +6 -0
- package/build/codemods/remove-overloads/remove-overloads.js +59 -0
- package/build/codemods/remove-overloads/transformers/filter-aware-usage-transformer.js +153 -0
- package/build/codemods/remove-overloads/transformers/query-fn-aware-usage-transformer.js +188 -0
- package/build/codemods/remove-overloads/utils/index.js +124 -0
- package/build/codemods/remove-overloads/utils/unknown-usage-error.js +27 -0
- package/build/codemods/src/utils/index.js +205 -0
- package/build/codemods/src/v4/key-transformation.js +138 -0
- package/build/codemods/src/v4/replace-import-specifier.js +25 -0
- package/build/codemods/transformers/query-cache-transformer.js +116 -0
- package/build/codemods/transformers/query-client-transformer.js +48 -0
- package/build/codemods/transformers/use-query-like-transformer.js +32 -0
- package/build/codemods/utils/replacers/key-replacer.js +164 -0
- package/build/lib/HydrationBoundary.cjs +50 -0
- package/build/lib/{HydrationBoundary.mjs.map → HydrationBoundary.cjs.map} +1 -1
- package/build/lib/HydrationBoundary.d.ts +1 -0
- package/build/lib/HydrationBoundary.d.ts.map +1 -0
- package/build/lib/HydrationBoundary.js +9 -29
- package/build/lib/HydrationBoundary.js.map +1 -1
- package/build/lib/HydrationBoundary.legacy.cjs +50 -0
- package/build/lib/HydrationBoundary.legacy.cjs.map +1 -0
- package/build/lib/{HydrationBoundary.esm.js → HydrationBoundary.legacy.js} +3 -2
- package/build/lib/HydrationBoundary.legacy.js.map +1 -0
- package/build/lib/QueryClientProvider.cjs +54 -0
- package/build/lib/QueryClientProvider.cjs.map +1 -0
- package/build/lib/QueryClientProvider.d.ts +2 -1
- package/build/lib/QueryClientProvider.d.ts.map +1 -0
- package/build/lib/QueryClientProvider.js +7 -29
- package/build/lib/QueryClientProvider.js.map +1 -1
- package/build/lib/QueryClientProvider.legacy.cjs +54 -0
- package/build/lib/QueryClientProvider.legacy.cjs.map +1 -0
- package/build/lib/{QueryClientProvider.esm.js → QueryClientProvider.legacy.js} +2 -1
- package/build/lib/QueryClientProvider.legacy.js.map +1 -0
- package/build/lib/QueryErrorResetBoundary.cjs +60 -0
- package/build/lib/{QueryErrorResetBoundary.mjs.map → QueryErrorResetBoundary.cjs.map} +1 -1
- package/build/lib/QueryErrorResetBoundary.d.ts +1 -0
- package/build/lib/QueryErrorResetBoundary.d.ts.map +1 -0
- package/build/lib/QueryErrorResetBoundary.js +7 -28
- package/build/lib/QueryErrorResetBoundary.js.map +1 -1
- package/build/lib/QueryErrorResetBoundary.legacy.cjs +60 -0
- package/build/lib/QueryErrorResetBoundary.legacy.cjs.map +1 -0
- package/build/lib/{QueryErrorResetBoundary.esm.js → QueryErrorResetBoundary.legacy.js} +2 -1
- package/build/lib/QueryErrorResetBoundary.legacy.js.map +1 -0
- package/build/lib/__tests__/HydrationBoundary.test.d.ts +1 -0
- package/build/lib/__tests__/HydrationBoundary.test.d.ts.map +1 -0
- package/build/lib/__tests__/QueryClientProvider.test.d.ts +1 -0
- package/build/lib/__tests__/QueryClientProvider.test.d.ts.map +1 -0
- package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts +1 -0
- package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts.map +1 -0
- package/build/lib/__tests__/ssr-hydration.test.d.ts +1 -0
- package/build/lib/__tests__/ssr-hydration.test.d.ts.map +1 -0
- package/build/lib/__tests__/ssr.test.d.ts +1 -0
- package/build/lib/__tests__/ssr.test.d.ts.map +1 -0
- package/build/lib/__tests__/suspense.test.d.ts +1 -0
- package/build/lib/__tests__/suspense.test.d.ts.map +1 -0
- package/build/lib/__tests__/useInfiniteQuery.test.d.ts +1 -0
- package/build/lib/__tests__/useInfiniteQuery.test.d.ts.map +1 -0
- package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts +1 -0
- package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts.map +1 -0
- package/build/lib/__tests__/useIsFetching.test.d.ts +1 -0
- package/build/lib/__tests__/useIsFetching.test.d.ts.map +1 -0
- package/build/lib/__tests__/useMutation.test.d.ts +1 -0
- package/build/lib/__tests__/useMutation.test.d.ts.map +1 -0
- package/build/lib/__tests__/useMutationState.test.d.ts +1 -0
- package/build/lib/__tests__/useMutationState.test.d.ts.map +1 -0
- package/build/lib/__tests__/useQueries.test.d.ts +1 -0
- package/build/lib/__tests__/useQueries.test.d.ts.map +1 -0
- package/build/lib/__tests__/useQuery.test.d.ts +1 -0
- package/build/lib/__tests__/useQuery.test.d.ts.map +1 -0
- package/build/lib/__tests__/useQuery.types.test.d.ts +1 -0
- package/build/lib/__tests__/useQuery.types.test.d.ts.map +1 -0
- package/build/lib/__tests__/utils.d.ts +3 -2
- package/build/lib/__tests__/utils.d.ts.map +1 -0
- package/build/lib/errorBoundaryUtils.cjs +51 -0
- package/build/lib/errorBoundaryUtils.cjs.map +1 -0
- package/build/lib/errorBoundaryUtils.d.ts +4 -3
- package/build/lib/errorBoundaryUtils.d.ts.map +1 -0
- package/build/lib/errorBoundaryUtils.js +8 -30
- package/build/lib/errorBoundaryUtils.js.map +1 -1
- package/build/lib/errorBoundaryUtils.legacy.cjs +51 -0
- package/build/lib/errorBoundaryUtils.legacy.cjs.map +1 -0
- package/build/lib/{errorBoundaryUtils.esm.js → errorBoundaryUtils.legacy.js} +6 -5
- package/build/lib/errorBoundaryUtils.legacy.js.map +1 -0
- package/build/lib/index.cjs +40 -0
- package/build/lib/index.cjs.map +1 -0
- package/build/lib/index.d.ts +2 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +12 -37
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.legacy.cjs +40 -0
- package/build/lib/index.legacy.cjs.map +1 -0
- package/build/lib/index.legacy.js +13 -0
- package/build/lib/index.legacy.js.map +1 -0
- package/build/lib/isRestoring.cjs +31 -0
- package/build/lib/isRestoring.cjs.map +1 -0
- package/build/lib/isRestoring.d.ts +1 -0
- package/build/lib/isRestoring.d.ts.map +1 -0
- package/build/lib/isRestoring.js +5 -26
- package/build/lib/isRestoring.js.map +1 -1
- package/build/lib/isRestoring.legacy.cjs +31 -0
- package/build/lib/isRestoring.legacy.cjs.map +1 -0
- package/build/lib/{isRestoring.esm.js → isRestoring.legacy.js} +2 -1
- package/build/lib/isRestoring.legacy.js.map +1 -0
- package/build/lib/queryOptions.cjs +8 -0
- package/build/lib/queryOptions.cjs.map +1 -0
- package/build/lib/queryOptions.d.ts +11 -0
- package/build/lib/queryOptions.d.ts.map +1 -0
- package/build/lib/queryOptions.js +6 -0
- package/build/lib/queryOptions.js.map +1 -0
- package/build/lib/queryOptions.legacy.cjs +8 -0
- package/build/lib/queryOptions.legacy.cjs.map +1 -0
- package/build/lib/queryOptions.legacy.js +6 -0
- package/build/lib/queryOptions.legacy.js.map +1 -0
- package/build/lib/suspense.cjs +22 -0
- package/build/lib/suspense.cjs.map +1 -0
- package/build/lib/suspense.d.ts +3 -5
- package/build/lib/suspense.d.ts.map +1 -0
- package/build/lib/suspense.js +3 -15
- package/build/lib/suspense.js.map +1 -1
- package/build/lib/{suspense.esm.js → suspense.legacy.cjs} +8 -10
- package/build/lib/suspense.legacy.cjs.map +1 -0
- package/build/lib/{suspense.mjs → suspense.legacy.js} +3 -10
- package/build/lib/suspense.legacy.js.map +1 -0
- package/build/lib/types.d.ts +11 -10
- package/build/lib/types.d.ts.map +1 -0
- package/build/lib/useBaseQuery.cjs +80 -0
- package/build/lib/useBaseQuery.cjs.map +1 -0
- package/build/lib/useBaseQuery.d.ts +1 -0
- package/build/lib/useBaseQuery.d.ts.map +1 -0
- package/build/lib/useBaseQuery.js +30 -54
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/useBaseQuery.legacy.cjs +80 -0
- package/build/lib/useBaseQuery.legacy.cjs.map +1 -0
- package/build/lib/{useBaseQuery.mjs → useBaseQuery.legacy.js} +16 -19
- package/build/lib/useBaseQuery.legacy.js.map +1 -0
- package/build/lib/useInfiniteQuery.cjs +15 -0
- package/build/lib/useInfiniteQuery.cjs.map +1 -0
- package/build/lib/useInfiniteQuery.d.ts +1 -0
- package/build/lib/useInfiniteQuery.d.ts.map +1 -0
- package/build/lib/useInfiniteQuery.js +6 -7
- package/build/lib/useInfiniteQuery.js.map +1 -1
- package/build/lib/useInfiniteQuery.legacy.cjs +15 -0
- package/build/lib/useInfiniteQuery.legacy.cjs.map +1 -0
- package/build/lib/{useInfiniteQuery.esm.js → useInfiniteQuery.legacy.js} +3 -2
- package/build/lib/useInfiniteQuery.legacy.js.map +1 -0
- package/build/lib/useIsFetching.cjs +34 -0
- package/build/lib/useIsFetching.cjs.map +1 -0
- package/build/lib/useIsFetching.d.ts +1 -0
- package/build/lib/useIsFetching.d.ts.map +1 -0
- package/build/lib/useIsFetching.js +7 -27
- package/build/lib/useIsFetching.js.map +1 -1
- package/build/lib/useIsFetching.legacy.cjs +34 -0
- package/build/lib/useIsFetching.legacy.cjs.map +1 -0
- package/build/lib/{useIsFetching.esm.js → useIsFetching.legacy.js} +3 -2
- package/build/lib/useIsFetching.legacy.js.map +1 -0
- package/build/lib/useMutation.cjs +54 -0
- package/build/lib/useMutation.cjs.map +1 -0
- package/build/lib/useMutation.d.ts +1 -0
- package/build/lib/useMutation.d.ts.map +1 -0
- package/build/lib/useMutation.js +12 -32
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.legacy.cjs +54 -0
- package/build/lib/useMutation.legacy.cjs.map +1 -0
- package/build/lib/{useMutation.esm.js → useMutation.legacy.js} +5 -4
- package/build/lib/useMutation.legacy.js.map +1 -0
- package/build/lib/useMutationState.cjs +60 -0
- package/build/lib/useMutationState.cjs.map +1 -0
- package/build/lib/useMutationState.d.ts +4 -3
- package/build/lib/useMutationState.d.ts.map +1 -0
- package/build/lib/useMutationState.js +13 -34
- package/build/lib/useMutationState.js.map +1 -1
- package/build/lib/useMutationState.legacy.cjs +60 -0
- package/build/lib/useMutationState.legacy.cjs.map +1 -0
- package/build/lib/{useMutationState.esm.js → useMutationState.legacy.js} +3 -2
- package/build/lib/useMutationState.legacy.js.map +1 -0
- package/build/lib/useQueries.cjs +99 -0
- package/build/lib/useQueries.cjs.map +1 -0
- package/build/lib/useQueries.d.ts +10 -8
- package/build/lib/useQueries.d.ts.map +1 -0
- package/build/lib/useQueries.js +52 -67
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQueries.legacy.cjs +102 -0
- package/build/lib/useQueries.legacy.cjs.map +1 -0
- package/build/lib/{useQueries.esm.js → useQueries.legacy.js} +37 -28
- package/build/lib/useQueries.legacy.js.map +1 -0
- package/build/lib/useQuery.cjs +14 -0
- package/build/lib/useQuery.cjs.map +1 -0
- package/build/lib/useQuery.d.ts +3 -8
- package/build/lib/useQuery.d.ts.map +1 -0
- package/build/lib/useQuery.js +5 -6
- package/build/lib/useQuery.js.map +1 -1
- package/build/lib/useQuery.legacy.cjs +14 -0
- package/build/lib/useQuery.legacy.cjs.map +1 -0
- package/build/lib/{useQuery.esm.js → useQuery.legacy.js} +3 -2
- package/build/lib/useQuery.legacy.js.map +1 -0
- package/build/lib/{utils.mjs → utils.cjs} +4 -2
- package/build/lib/{utils.mjs.map → utils.cjs.map} +1 -1
- package/build/lib/utils.d.ts +1 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +1 -3
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.legacy.cjs +12 -0
- package/build/lib/utils.legacy.cjs.map +1 -0
- package/build/lib/{utils.esm.js → utils.legacy.js} +1 -1
- package/build/lib/utils.legacy.js.map +1 -0
- package/package.json +25 -15
- package/src/__tests__/QueryResetErrorBoundary.test.tsx +752 -620
- package/src/__tests__/ssr-hydration.test.tsx +2 -2
- package/src/__tests__/suspense.test.tsx +6 -88
- package/src/__tests__/useInfiniteQuery.type.test.tsx +0 -27
- package/src/__tests__/useMutation.test.tsx +4 -4
- package/src/__tests__/useMutationState.test.tsx +23 -0
- package/src/__tests__/useQueries.test.tsx +206 -83
- package/src/__tests__/useQuery.test.tsx +246 -338
- package/src/__tests__/useQuery.types.test.tsx +21 -0
- package/src/errorBoundaryUtils.ts +6 -5
- package/src/index.ts +1 -0
- package/src/queryOptions.ts +42 -0
- package/src/suspense.ts +9 -15
- package/src/useBaseQuery.ts +12 -23
- package/src/useInfiniteQuery.ts +1 -0
- package/src/useIsFetching.ts +1 -0
- package/src/useMutation.ts +2 -1
- package/src/useMutationState.ts +4 -3
- package/src/useQueries.ts +44 -26
- package/src/useQuery.ts +5 -17
- package/build/lib/HydrationBoundary.esm.js.map +0 -1
- package/build/lib/HydrationBoundary.mjs +0 -28
- package/build/lib/QueryClientProvider.esm.js.map +0 -1
- package/build/lib/QueryClientProvider.mjs +0 -30
- package/build/lib/QueryClientProvider.mjs.map +0 -1
- package/build/lib/QueryErrorResetBoundary.esm.js.map +0 -1
- package/build/lib/QueryErrorResetBoundary.mjs +0 -37
- package/build/lib/errorBoundaryUtils.esm.js.map +0 -1
- package/build/lib/errorBoundaryUtils.mjs +0 -27
- package/build/lib/errorBoundaryUtils.mjs.map +0 -1
- package/build/lib/index.esm.js +0 -12
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.mjs +0 -12
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/isRestoring.esm.js.map +0 -1
- package/build/lib/isRestoring.mjs +0 -8
- package/build/lib/isRestoring.mjs.map +0 -1
- package/build/lib/suspense.esm.js.map +0 -1
- package/build/lib/suspense.mjs.map +0 -1
- package/build/lib/useBaseQuery.esm.js +0 -62
- package/build/lib/useBaseQuery.esm.js.map +0 -1
- package/build/lib/useBaseQuery.mjs.map +0 -1
- package/build/lib/useInfiniteQuery.esm.js.map +0 -1
- package/build/lib/useInfiniteQuery.mjs +0 -12
- package/build/lib/useInfiniteQuery.mjs.map +0 -1
- package/build/lib/useIsFetching.esm.js.map +0 -1
- package/build/lib/useIsFetching.mjs +0 -12
- package/build/lib/useIsFetching.mjs.map +0 -1
- package/build/lib/useMutation.esm.js.map +0 -1
- package/build/lib/useMutation.mjs +0 -32
- package/build/lib/useMutation.mjs.map +0 -1
- package/build/lib/useMutationState.esm.js.map +0 -1
- package/build/lib/useMutationState.mjs +0 -37
- package/build/lib/useMutationState.mjs.map +0 -1
- package/build/lib/useQueries.esm.js.map +0 -1
- package/build/lib/useQueries.mjs +0 -69
- package/build/lib/useQueries.mjs.map +0 -1
- package/build/lib/useQuery.esm.js.map +0 -1
- package/build/lib/useQuery.mjs +0 -11
- package/build/lib/useQuery.mjs.map +0 -1
- package/build/lib/utils.esm.js.map +0 -1
- package/build/umd/index.development.js +0 -3040
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -2
- package/build/umd/index.production.js.map +0 -1
- /package/src/{isRestoring.tsx → isRestoring.ts} +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from 'react-query'
|
|
3
|
+
|
|
4
|
+
const options = {}
|
|
5
|
+
|
|
6
|
+
export const ExampleWithStringLiteral = () => {
|
|
7
|
+
useQuery({ queryKey: 'todos', exact: true }, options)
|
|
8
|
+
useMutation({ mutationKey: 'todos', exact: true }, options)
|
|
9
|
+
// QueryClient methods
|
|
10
|
+
// --- Instantiated hook call.
|
|
11
|
+
const queryClient = useQueryClient()
|
|
12
|
+
queryClient.cancelQueries({ queryKey: 'todos', exact: true }, options)
|
|
13
|
+
// --- Direct hook call.
|
|
14
|
+
useQueryClient().cancelQueries({ queryKey: 'todos', exact: true }, options)
|
|
15
|
+
|
|
16
|
+
return <div>Example Component</div>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ExampleWithStringLiteralIdentifier = () => {
|
|
20
|
+
const stringLiteralKey = 'todos'
|
|
21
|
+
useQuery({ queryKey: stringLiteralKey, exact: true }, options)
|
|
22
|
+
useMutation({ mutationKey: stringLiteralKey, exact: true }, options)
|
|
23
|
+
// QueryClient methods
|
|
24
|
+
// --- Instantiated hook call.
|
|
25
|
+
const queryClient = useQueryClient()
|
|
26
|
+
queryClient.cancelQueries({ queryKey: stringLiteralKey, exact: true }, options)
|
|
27
|
+
// --- Direct hook call.
|
|
28
|
+
useQueryClient().cancelQueries({ queryKey: stringLiteralKey, exact: true }, options)
|
|
29
|
+
|
|
30
|
+
return <div>Example Component</div>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const ExampleWithTemplateLiteral = () => {
|
|
34
|
+
useQuery({ queryKey: `todos`, exact: true }, options)
|
|
35
|
+
useMutation({ mutationKey: `todos`, exact: true }, options)
|
|
36
|
+
// QueryClient methods
|
|
37
|
+
// --- Instantiated hook call.
|
|
38
|
+
const queryClient = useQueryClient()
|
|
39
|
+
queryClient.cancelQueries({ queryKey: `todos`, exact: true }, options)
|
|
40
|
+
// --- Direct hook call.
|
|
41
|
+
useQueryClient().cancelQueries({ queryKey: `todos`, exact: true }, options)
|
|
42
|
+
|
|
43
|
+
return <div>Example Component</div>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const ExampleWithTemplateLiteralIdentifier = () => {
|
|
47
|
+
const templateLiteralKey = `todos`
|
|
48
|
+
useQuery({ queryKey: templateLiteralKey, exact: true }, options)
|
|
49
|
+
useMutation({ mutationKey: templateLiteralKey, exact: true }, options)
|
|
50
|
+
// QueryClient methods
|
|
51
|
+
// --- Instantiated hook call.
|
|
52
|
+
const queryClient = useQueryClient()
|
|
53
|
+
queryClient.cancelQueries({ queryKey: templateLiteralKey, exact: true }, options)
|
|
54
|
+
// --- Direct hook call.
|
|
55
|
+
useQueryClient().cancelQueries({ queryKey: templateLiteralKey, exact: true }, options)
|
|
56
|
+
|
|
57
|
+
return <div>Example Component</div>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const ExampleWithArrayExpression = () => {
|
|
61
|
+
useQuery({ queryKey: ['todos'], exact: true }, options)
|
|
62
|
+
useMutation({ mutationKey: ['todos'], exact: true }, options)
|
|
63
|
+
// QueryClient methods
|
|
64
|
+
// --- Instantiated hook call.
|
|
65
|
+
const queryClient = useQueryClient()
|
|
66
|
+
queryClient.cancelQueries({ queryKey: ['todos'], exact: true }, options)
|
|
67
|
+
// --- Direct hook call.
|
|
68
|
+
useQueryClient().cancelQueries({ queryKey: ['todos'], exact: true }, options)
|
|
69
|
+
|
|
70
|
+
return <div>Example Component</div>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const ExampleWithArrayExpressionIdentifier = () => {
|
|
74
|
+
const arrayExpressionKey = ['todos']
|
|
75
|
+
useQuery({ queryKey: arrayExpressionKey, exact: true }, options)
|
|
76
|
+
useMutation({ mutationKey: arrayExpressionKey, exact: true }, options)
|
|
77
|
+
// QueryClient methods
|
|
78
|
+
// --- Instantiated hook call.
|
|
79
|
+
const queryClient = useQueryClient()
|
|
80
|
+
queryClient.cancelQueries({ queryKey: arrayExpressionKey, exact: true }, options)
|
|
81
|
+
// --- Direct hook call.
|
|
82
|
+
useQueryClient().cancelQueries({ queryKey: arrayExpressionKey, exact: true }, options)
|
|
83
|
+
|
|
84
|
+
return <div>Example Component</div>
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const ExampleWithUnknownIdentifier1 = () => {
|
|
88
|
+
const createKey = (id) => ['todos', id]
|
|
89
|
+
const createdKey1 = createKey(1)
|
|
90
|
+
useQuery({ queryKey: createdKey1, exact: true }, options)
|
|
91
|
+
useMutation({ mutationKey: createdKey1, exact: true }, options)
|
|
92
|
+
// QueryClient methods
|
|
93
|
+
// --- Instantiated hook call.
|
|
94
|
+
const queryClient = useQueryClient()
|
|
95
|
+
queryClient.cancelQueries({ queryKey: createdKey1, exact: true }, options)
|
|
96
|
+
// --- Direct hook call.
|
|
97
|
+
useQueryClient().cancelQueries({ queryKey: createdKey1, exact: true }, options)
|
|
98
|
+
|
|
99
|
+
return <div>Example Component</div>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const ExampleWithUnknownIdentifier2 = () => {
|
|
103
|
+
const createdKey2 = createKey()
|
|
104
|
+
useQuery({ queryKey: createdKey2, exact: true }, options)
|
|
105
|
+
useMutation({ mutationKey: createdKey2, exact: true }, options)
|
|
106
|
+
// QueryClient methods
|
|
107
|
+
// --- Instantiated hook call.
|
|
108
|
+
const queryClient = useQueryClient()
|
|
109
|
+
queryClient.cancelQueries({ queryKey: createdKey2, exact: true }, options)
|
|
110
|
+
// --- Direct hook call.
|
|
111
|
+
useQueryClient().cancelQueries({ queryKey: createdKey2, exact: true }, options)
|
|
112
|
+
|
|
113
|
+
return <div>Example Component</div>
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const ExampleWithUnknownIdentifier3 = () => {
|
|
117
|
+
useQuery({ queryKey: unknownQueryKey, exact: true }, options)
|
|
118
|
+
useMutation({ mutationKey: unknownQueryKey, exact: true }, options)
|
|
119
|
+
// QueryClient methods
|
|
120
|
+
// --- Instantiated hook call.
|
|
121
|
+
const queryClient = useQueryClient()
|
|
122
|
+
queryClient.cancelQueries({ queryKey: unknownQueryKey, exact: true }, options)
|
|
123
|
+
// --- Direct hook call.
|
|
124
|
+
useQueryClient().cancelQueries({ queryKey: unknownQueryKey, exact: true }, options)
|
|
125
|
+
|
|
126
|
+
return <div>Example Component</div>
|
|
127
|
+
}
|
|
128
|
+
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from 'react-query'
|
|
3
|
+
|
|
4
|
+
const options = {}
|
|
5
|
+
|
|
6
|
+
export const ExampleWithStringLiteral = () => {
|
|
7
|
+
useQuery({
|
|
8
|
+
queryKey: ['todos'],
|
|
9
|
+
exact: true
|
|
10
|
+
}, options)
|
|
11
|
+
useMutation({
|
|
12
|
+
mutationKey: ['todos'],
|
|
13
|
+
exact: true
|
|
14
|
+
}, options)
|
|
15
|
+
// QueryClient methods
|
|
16
|
+
// --- Instantiated hook call.
|
|
17
|
+
const queryClient = useQueryClient()
|
|
18
|
+
queryClient.cancelQueries({
|
|
19
|
+
queryKey: ['todos'],
|
|
20
|
+
exact: true
|
|
21
|
+
}, options)
|
|
22
|
+
// --- Direct hook call.
|
|
23
|
+
useQueryClient().cancelQueries({
|
|
24
|
+
queryKey: ['todos'],
|
|
25
|
+
exact: true
|
|
26
|
+
}, options)
|
|
27
|
+
|
|
28
|
+
return <div>Example Component</div>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const ExampleWithStringLiteralIdentifier = () => {
|
|
32
|
+
const stringLiteralKey = 'todos'
|
|
33
|
+
useQuery({
|
|
34
|
+
queryKey: [stringLiteralKey],
|
|
35
|
+
exact: true
|
|
36
|
+
}, options)
|
|
37
|
+
useMutation({
|
|
38
|
+
mutationKey: [stringLiteralKey],
|
|
39
|
+
exact: true
|
|
40
|
+
}, options)
|
|
41
|
+
// QueryClient methods
|
|
42
|
+
// --- Instantiated hook call.
|
|
43
|
+
const queryClient = useQueryClient()
|
|
44
|
+
queryClient.cancelQueries({
|
|
45
|
+
queryKey: [stringLiteralKey],
|
|
46
|
+
exact: true
|
|
47
|
+
}, options)
|
|
48
|
+
// --- Direct hook call.
|
|
49
|
+
useQueryClient().cancelQueries({
|
|
50
|
+
queryKey: [stringLiteralKey],
|
|
51
|
+
exact: true
|
|
52
|
+
}, options)
|
|
53
|
+
|
|
54
|
+
return <div>Example Component</div>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const ExampleWithTemplateLiteral = () => {
|
|
58
|
+
useQuery({
|
|
59
|
+
queryKey: [`todos`],
|
|
60
|
+
exact: true
|
|
61
|
+
}, options)
|
|
62
|
+
useMutation({
|
|
63
|
+
mutationKey: [`todos`],
|
|
64
|
+
exact: true
|
|
65
|
+
}, options)
|
|
66
|
+
// QueryClient methods
|
|
67
|
+
// --- Instantiated hook call.
|
|
68
|
+
const queryClient = useQueryClient()
|
|
69
|
+
queryClient.cancelQueries({
|
|
70
|
+
queryKey: [`todos`],
|
|
71
|
+
exact: true
|
|
72
|
+
}, options)
|
|
73
|
+
// --- Direct hook call.
|
|
74
|
+
useQueryClient().cancelQueries({
|
|
75
|
+
queryKey: [`todos`],
|
|
76
|
+
exact: true
|
|
77
|
+
}, options)
|
|
78
|
+
|
|
79
|
+
return <div>Example Component</div>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const ExampleWithTemplateLiteralIdentifier = () => {
|
|
83
|
+
const templateLiteralKey = `todos`
|
|
84
|
+
useQuery({
|
|
85
|
+
queryKey: [templateLiteralKey],
|
|
86
|
+
exact: true
|
|
87
|
+
}, options)
|
|
88
|
+
useMutation({
|
|
89
|
+
mutationKey: [templateLiteralKey],
|
|
90
|
+
exact: true
|
|
91
|
+
}, options)
|
|
92
|
+
// QueryClient methods
|
|
93
|
+
// --- Instantiated hook call.
|
|
94
|
+
const queryClient = useQueryClient()
|
|
95
|
+
queryClient.cancelQueries({
|
|
96
|
+
queryKey: [templateLiteralKey],
|
|
97
|
+
exact: true
|
|
98
|
+
}, options)
|
|
99
|
+
// --- Direct hook call.
|
|
100
|
+
useQueryClient().cancelQueries({
|
|
101
|
+
queryKey: [templateLiteralKey],
|
|
102
|
+
exact: true
|
|
103
|
+
}, options)
|
|
104
|
+
|
|
105
|
+
return <div>Example Component</div>
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const ExampleWithArrayExpression = () => {
|
|
109
|
+
useQuery({ queryKey: ['todos'], exact: true }, options)
|
|
110
|
+
useMutation({ mutationKey: ['todos'], exact: true }, options)
|
|
111
|
+
// QueryClient methods
|
|
112
|
+
// --- Instantiated hook call.
|
|
113
|
+
const queryClient = useQueryClient()
|
|
114
|
+
queryClient.cancelQueries({ queryKey: ['todos'], exact: true }, options)
|
|
115
|
+
// --- Direct hook call.
|
|
116
|
+
useQueryClient().cancelQueries({ queryKey: ['todos'], exact: true }, options)
|
|
117
|
+
|
|
118
|
+
return <div>Example Component</div>
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export const ExampleWithArrayExpressionIdentifier = () => {
|
|
122
|
+
const arrayExpressionKey = ['todos']
|
|
123
|
+
useQuery({ queryKey: arrayExpressionKey, exact: true }, options)
|
|
124
|
+
useMutation({ mutationKey: arrayExpressionKey, exact: true }, options)
|
|
125
|
+
// QueryClient methods
|
|
126
|
+
// --- Instantiated hook call.
|
|
127
|
+
const queryClient = useQueryClient()
|
|
128
|
+
queryClient.cancelQueries({ queryKey: arrayExpressionKey, exact: true }, options)
|
|
129
|
+
// --- Direct hook call.
|
|
130
|
+
useQueryClient().cancelQueries({ queryKey: arrayExpressionKey, exact: true }, options)
|
|
131
|
+
|
|
132
|
+
return <div>Example Component</div>
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const ExampleWithUnknownIdentifier1 = () => {
|
|
136
|
+
const createKey = (id) => ['todos', id]
|
|
137
|
+
const createdKey1 = createKey(1)
|
|
138
|
+
useQuery({ queryKey: createdKey1, exact: true }, options)
|
|
139
|
+
useMutation({ mutationKey: createdKey1, exact: true }, options)
|
|
140
|
+
// QueryClient methods
|
|
141
|
+
// --- Instantiated hook call.
|
|
142
|
+
const queryClient = useQueryClient()
|
|
143
|
+
queryClient.cancelQueries({ queryKey: createdKey1, exact: true }, options)
|
|
144
|
+
// --- Direct hook call.
|
|
145
|
+
useQueryClient().cancelQueries({ queryKey: createdKey1, exact: true }, options)
|
|
146
|
+
|
|
147
|
+
return <div>Example Component</div>
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const ExampleWithUnknownIdentifier2 = () => {
|
|
151
|
+
const createdKey2 = createKey()
|
|
152
|
+
useQuery({ queryKey: createdKey2, exact: true }, options)
|
|
153
|
+
useMutation({ mutationKey: createdKey2, exact: true }, options)
|
|
154
|
+
// QueryClient methods
|
|
155
|
+
// --- Instantiated hook call.
|
|
156
|
+
const queryClient = useQueryClient()
|
|
157
|
+
queryClient.cancelQueries({ queryKey: createdKey2, exact: true }, options)
|
|
158
|
+
// --- Direct hook call.
|
|
159
|
+
useQueryClient().cancelQueries({ queryKey: createdKey2, exact: true }, options)
|
|
160
|
+
|
|
161
|
+
return <div>Example Component</div>
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const ExampleWithUnknownIdentifier3 = () => {
|
|
165
|
+
useQuery({ queryKey: unknownQueryKey, exact: true }, options)
|
|
166
|
+
useMutation({ mutationKey: unknownQueryKey, exact: true }, options)
|
|
167
|
+
// QueryClient methods
|
|
168
|
+
// --- Instantiated hook call.
|
|
169
|
+
const queryClient = useQueryClient()
|
|
170
|
+
queryClient.cancelQueries({ queryKey: unknownQueryKey, exact: true }, options)
|
|
171
|
+
// --- Direct hook call.
|
|
172
|
+
useQueryClient().cancelQueries({ queryKey: unknownQueryKey, exact: true }, options)
|
|
173
|
+
|
|
174
|
+
return <div>Example Component</div>
|
|
175
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// React Query
|
|
2
|
+
import { useQuery, useQueryClient } from 'react-query'
|
|
3
|
+
import { useQuery as RenamedUseQuery, useQueryClient as RenamedUseQueryClient } from 'react-query'
|
|
4
|
+
import DefaultReactQuery from 'react-query'
|
|
5
|
+
import * as NamespacedReactQuery from 'react-query'
|
|
6
|
+
// Devtools
|
|
7
|
+
import { ReactQueryDevtools } from 'react-query/devtools'
|
|
8
|
+
import { ReactQueryDevtools as RenamedReactQueryDevtools } from 'react-query/devtools'
|
|
9
|
+
import DefaultReactQueryDevtools from 'react-query/devtools'
|
|
10
|
+
import * as NamespacedReactQueryDevtools from 'react-query/devtools'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// React Query
|
|
2
|
+
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
|
3
|
+
import { useQuery as RenamedUseQuery, useQueryClient as RenamedUseQueryClient } from '@tanstack/react-query'
|
|
4
|
+
import DefaultReactQuery from '@tanstack/react-query'
|
|
5
|
+
import * as NamespacedReactQuery from '@tanstack/react-query'
|
|
6
|
+
// Devtools
|
|
7
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
8
|
+
import { ReactQueryDevtools as RenamedReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
9
|
+
import DefaultReactQueryDevtools from '@tanstack/react-query-devtools'
|
|
10
|
+
import * as NamespacedReactQueryDevtools from '@tanstack/react-query-devtools'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { useQueries, useQuery, useQueryClient } from 'react-query'
|
|
3
|
+
|
|
4
|
+
type Todos = {
|
|
5
|
+
items: readonly {
|
|
6
|
+
id: string
|
|
7
|
+
text: string
|
|
8
|
+
}[]
|
|
9
|
+
ts: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Examples = () => {
|
|
13
|
+
useQuery<Todos>('todos')
|
|
14
|
+
useQueries<Array<Todos>>([query1, query2])
|
|
15
|
+
// QueryClient methods
|
|
16
|
+
// --- Instantiated hook call.
|
|
17
|
+
const queryClient = useQueryClient()
|
|
18
|
+
queryClient.getQueriesData<Todos>('todos')
|
|
19
|
+
queryClient.getQueriesData<Todos>({ queryKey: 'todos' })
|
|
20
|
+
// --- Direct hook call.
|
|
21
|
+
useQueryClient().getQueriesData<Todos>('todos')
|
|
22
|
+
useQueryClient().getQueriesData<Todos>({ queryKey: 'todos' })
|
|
23
|
+
|
|
24
|
+
return <div>Example Component</div>
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { useQueries, useQuery, useQueryClient } from 'react-query'
|
|
3
|
+
|
|
4
|
+
type Todos = {
|
|
5
|
+
items: readonly {
|
|
6
|
+
id: string
|
|
7
|
+
text: string
|
|
8
|
+
}[]
|
|
9
|
+
ts: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Examples = () => {
|
|
13
|
+
useQuery<Todos>(['todos'])
|
|
14
|
+
useQueries<Array<Todos>>({
|
|
15
|
+
queries: [query1, query2]
|
|
16
|
+
})
|
|
17
|
+
// QueryClient methods
|
|
18
|
+
// --- Instantiated hook call.
|
|
19
|
+
const queryClient = useQueryClient()
|
|
20
|
+
queryClient.getQueriesData<Todos>(['todos'])
|
|
21
|
+
queryClient.getQueriesData<Todos>({
|
|
22
|
+
queryKey: ['todos']
|
|
23
|
+
})
|
|
24
|
+
// --- Direct hook call.
|
|
25
|
+
useQueryClient().getQueriesData<Todos>(['todos'])
|
|
26
|
+
useQueryClient().getQueriesData<Todos>({
|
|
27
|
+
queryKey: ['todos']
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return <div>Example Component</div>
|
|
31
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2
|
+
const defineTest = require('jscodeshift/dist/testUtils').defineTest
|
|
3
|
+
|
|
4
|
+
defineTest(__dirname, 'key-transformation', null, 'default-import', {
|
|
5
|
+
parser: 'tsx',
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
defineTest(__dirname, 'key-transformation', null, 'named-import', {
|
|
9
|
+
parser: 'tsx',
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
defineTest(__dirname, 'key-transformation', null, 'namespaced-import', {
|
|
13
|
+
parser: 'tsx',
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
defineTest(__dirname, 'key-transformation', null, 'parameter-is-identifier', {
|
|
17
|
+
parser: 'tsx',
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
defineTest(
|
|
21
|
+
__dirname,
|
|
22
|
+
'key-transformation',
|
|
23
|
+
null,
|
|
24
|
+
'parameter-is-object-expression',
|
|
25
|
+
{
|
|
26
|
+
parser: 'tsx',
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
defineTest(__dirname, 'key-transformation', null, 'type-arguments', {
|
|
31
|
+
parser: 'tsx',
|
|
32
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2
|
+
const defineTest = require('jscodeshift/dist/testUtils').defineTest
|
|
3
|
+
|
|
4
|
+
defineTest(
|
|
5
|
+
__dirname,
|
|
6
|
+
'replace-import-specifier',
|
|
7
|
+
null,
|
|
8
|
+
'replace-import-specifier',
|
|
9
|
+
{
|
|
10
|
+
parser: 'tsx',
|
|
11
|
+
},
|
|
12
|
+
)
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
useIsFetching,
|
|
4
|
+
useIsMutating,
|
|
5
|
+
useQueryClient,
|
|
6
|
+
} from '@tanstack/react-query'
|
|
7
|
+
import { queryKeysFromAnotherModule } from '../another/module'
|
|
8
|
+
|
|
9
|
+
export const WithKnownParameters = () => {
|
|
10
|
+
useIsFetching(['foo', 'bar'])
|
|
11
|
+
useIsFetching(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
12
|
+
useIsFetching(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true }, { context: undefined })
|
|
13
|
+
useIsFetching(['foo', 'bar'], { type: 'all', exact: true })
|
|
14
|
+
useIsFetching(['foo', 'bar'], { type: 'all', exact: true }, { context: undefined })
|
|
15
|
+
useIsFetching({ queryKey: ['foo', 'bar'], type: 'all', exact: true })
|
|
16
|
+
useIsFetching({ queryKey: ['foo', 'bar'], type: 'all', exact: true }, { context: undefined })
|
|
17
|
+
|
|
18
|
+
useIsMutating(['foo', 'bar'])
|
|
19
|
+
useIsMutating(['foo', 'bar'], { exact: true })
|
|
20
|
+
useIsMutating(['foo', 'bar'], { exact: true }, { context: undefined })
|
|
21
|
+
useIsMutating({ mutationKey: ['foo', 'bar'], exact: true })
|
|
22
|
+
useIsMutating({ mutationKey: ['foo', 'bar'], exact: true }, { context: undefined })
|
|
23
|
+
|
|
24
|
+
// QueryClient methods
|
|
25
|
+
// --- Instantiated hook call.
|
|
26
|
+
const queryClient = useQueryClient()
|
|
27
|
+
queryClient.cancelQueries(['foo', 'bar'])
|
|
28
|
+
queryClient.cancelQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
29
|
+
queryClient.cancelQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true }, { silent: true })
|
|
30
|
+
queryClient.cancelQueries(['foo', 'bar'], { type: 'all', exact: true })
|
|
31
|
+
queryClient.cancelQueries(['foo', 'bar'], { type: 'all', exact: true }, { silent: true })
|
|
32
|
+
queryClient.cancelQueries({ queryKey: ['foo', 'bar'], type: 'all', exact: true })
|
|
33
|
+
queryClient.cancelQueries({ queryKey: ['foo', 'bar'], type: 'all', exact: true }, { silent: true })
|
|
34
|
+
|
|
35
|
+
queryClient.getQueriesData(['foo', 'bar'])
|
|
36
|
+
queryClient.getQueriesData({ queryKey: ['foo', 'bar'], type: 'all', exact: true })
|
|
37
|
+
|
|
38
|
+
queryClient.invalidateQueries(['foo', 'bar'])
|
|
39
|
+
queryClient.invalidateQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
40
|
+
queryClient.invalidateQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
41
|
+
queryClient.invalidateQueries(['foo', 'bar'], { type: 'all', exact: true })
|
|
42
|
+
queryClient.invalidateQueries(['foo', 'bar'], { type: 'all', exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
43
|
+
queryClient.invalidateQueries({ queryKey: ['foo', 'bar'], type: 'all', exact: true })
|
|
44
|
+
queryClient.invalidateQueries({ queryKey: ['foo', 'bar'], type: 'all', exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
45
|
+
|
|
46
|
+
queryClient.isFetching(['foo', 'bar'])
|
|
47
|
+
queryClient.isFetching(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
48
|
+
queryClient.isFetching(['foo', 'bar'], { type: 'all', exact: true })
|
|
49
|
+
queryClient.isFetching({ queryKey: ['foo', 'bar'], type: 'all', exact: true })
|
|
50
|
+
|
|
51
|
+
queryClient.refetchQueries(['foo', 'bar'])
|
|
52
|
+
queryClient.refetchQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
53
|
+
queryClient.refetchQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
54
|
+
queryClient.refetchQueries(['foo', 'bar'], { type: 'all', exact: true })
|
|
55
|
+
queryClient.refetchQueries(['foo', 'bar'], { type: 'all', exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
56
|
+
queryClient.refetchQueries({ queryKey: ['foo', 'bar'], type: 'all', exact: true })
|
|
57
|
+
queryClient.refetchQueries({ queryKey: ['foo', 'bar'], type: 'all', exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
58
|
+
|
|
59
|
+
queryClient.removeQueries(['foo', 'bar'])
|
|
60
|
+
queryClient.removeQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
61
|
+
queryClient.removeQueries({ queryKey: ['foo', 'bar'], type: 'all', exact: true })
|
|
62
|
+
|
|
63
|
+
queryClient.resetQueries(['foo', 'bar'])
|
|
64
|
+
queryClient.resetQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
65
|
+
queryClient.resetQueries(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
66
|
+
queryClient.resetQueries(['foo', 'bar'], { type: 'all', exact: true })
|
|
67
|
+
queryClient.resetQueries(['foo', 'bar'], { type: 'all', exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
68
|
+
queryClient.resetQueries({ queryKey: ['foo', 'bar'], exact: true })
|
|
69
|
+
queryClient.resetQueries({ queryKey: ['foo', 'bar'], exact: true }, { cancelRefetch: false, throwOnError: true })
|
|
70
|
+
|
|
71
|
+
queryClient.setQueriesData(['foo', 'bar'], null)
|
|
72
|
+
queryClient.setQueriesData(['foo', 'bar'], null, { updatedAt: 1000 })
|
|
73
|
+
queryClient.setQueriesData({ queryKey: ['foo', 'bar'] }, null)
|
|
74
|
+
queryClient.setQueriesData({ queryKey: ['foo', 'bar'] }, null, { updatedAt: 1000 })
|
|
75
|
+
|
|
76
|
+
queryClient.fetchQuery(['foo', 'bar'])
|
|
77
|
+
queryClient.fetchQuery(['foo', 'bar'], { queryKey: ['todos'], staleTime: 1000 })
|
|
78
|
+
queryClient.fetchQuery(['foo', 'bar'], { queryKey: ['todos'], queryFn: () => 'data', staleTime: 1000 })
|
|
79
|
+
queryClient.fetchQuery(['foo', 'bar'], () => 'data', { queryKey: ['todos'], staleTime: 1000 })
|
|
80
|
+
queryClient.fetchQuery(['foo', 'bar'], function myFn() { return 'data' }, { queryKey: ['todos'], staleTime: 1000 })
|
|
81
|
+
queryClient.fetchQuery({ queryKey: ['foo', 'bar'], queryFn: () => 'data', retry: true })
|
|
82
|
+
|
|
83
|
+
const queryCache = queryClient.getQueryCache()
|
|
84
|
+
|
|
85
|
+
queryCache.find(['foo', 'bar'])
|
|
86
|
+
queryCache.find(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
87
|
+
queryCache.find(['foo', 'bar'], { type: 'all', exact: true })
|
|
88
|
+
|
|
89
|
+
queryCache.findAll(['foo', 'bar'])
|
|
90
|
+
queryCache.findAll(['foo', 'bar'], { type: 'all', exact: true })
|
|
91
|
+
queryCache.findAll(['foo', 'bar'], { queryKey: ['todos'], type: 'all', exact: true })
|
|
92
|
+
queryCache.findAll({ queryKey: ['foo', 'bar'], type: 'all', exact: true })
|
|
93
|
+
|
|
94
|
+
return <div>Example Component</div>
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const globalQueryKey = ['module', 'level']
|
|
98
|
+
|
|
99
|
+
export const WithIdentifiers = () => {
|
|
100
|
+
const queryKey = ['foo', 'bar']
|
|
101
|
+
const mutationKey = ['posts', 'articles']
|
|
102
|
+
const filters = { type: 'all', exact: true } as const
|
|
103
|
+
const options = { context: undefined } as const
|
|
104
|
+
const mutationOptions = { exact: true, fetching: false } as const
|
|
105
|
+
const cancelOptions = { silent: true } as const
|
|
106
|
+
const invalidateOptions = { cancelRefetch: true, throwOnError: true } as const
|
|
107
|
+
const refetchOptions = { cancelRefetch: false, throwOnError: true } as const
|
|
108
|
+
const resetOptions = { cancelRefetch: false, throwOnError: true } as const
|
|
109
|
+
const fetchOptions = { queryFn: () => 'data', retry: true } as const
|
|
110
|
+
const queryFn = () => 'data'
|
|
111
|
+
|
|
112
|
+
useIsFetching(queryKey)
|
|
113
|
+
useIsFetching(queryKey, filters)
|
|
114
|
+
useIsFetching(queryKey, filters, options)
|
|
115
|
+
useIsFetching(queryKey, { type: 'all', exact: true })
|
|
116
|
+
useIsFetching(queryKey, { type: 'all', exact: true }, { context: undefined })
|
|
117
|
+
useIsFetching(queryKey, { queryKey: ['todos'], ...filters }, options)
|
|
118
|
+
useIsFetching({ queryKey: queryKey, ...filters })
|
|
119
|
+
useIsFetching({ queryKey: queryKey, ...filters }, { context: undefined })
|
|
120
|
+
|
|
121
|
+
useIsMutating(mutationKey)
|
|
122
|
+
useIsMutating(mutationKey, { exact: true, status: 'idle' })
|
|
123
|
+
useIsMutating(mutationKey, { ...mutationOptions, exact: false })
|
|
124
|
+
useIsMutating({ mutationKey, ...mutationOptions })
|
|
125
|
+
useIsMutating({ mutationKey: ['foo', 'bar'], exact: true, status: 'idle' })
|
|
126
|
+
|
|
127
|
+
// QueryClient methods
|
|
128
|
+
// --- Instantiated hook call.
|
|
129
|
+
const queryClient = useQueryClient()
|
|
130
|
+
queryClient.cancelQueries(queryKey)
|
|
131
|
+
queryClient.cancelQueries(queryKey, filters)
|
|
132
|
+
queryClient.cancelQueries(queryKey, filters, cancelOptions)
|
|
133
|
+
queryClient.cancelQueries(queryKey, { type: 'all', exact: true })
|
|
134
|
+
queryClient.cancelQueries(queryKey, { type: 'all', exact: true }, { revert: true })
|
|
135
|
+
queryClient.cancelQueries(queryKey, { queryKey: ['todos'], ...filters }, cancelOptions)
|
|
136
|
+
queryClient.cancelQueries({ queryKey: queryKey, type: 'all', exact: true })
|
|
137
|
+
queryClient.cancelQueries({ queryKey: ['foo', 'bar'], ...filters }, cancelOptions)
|
|
138
|
+
|
|
139
|
+
queryClient.getQueriesData(globalQueryKey)
|
|
140
|
+
queryClient.getQueriesData({ queryKey: globalQueryKey, ...filters })
|
|
141
|
+
queryClient.getQueriesData({ queryKey: ['foo', 'bar'], type: 'all' })
|
|
142
|
+
|
|
143
|
+
queryClient.invalidateQueries(queryKey)
|
|
144
|
+
queryClient.invalidateQueries(queryKey, filters)
|
|
145
|
+
queryClient.invalidateQueries(queryKey, filters, invalidateOptions)
|
|
146
|
+
queryClient.invalidateQueries(queryKey, { queryKey: ['todos'], stale: true, ...filters })
|
|
147
|
+
queryClient.invalidateQueries(queryKey, { queryKey: ['todos'], stale: true, ...filters }, invalidateOptions)
|
|
148
|
+
queryClient.invalidateQueries({ queryKey: globalQueryKey, ...filters, stale: true })
|
|
149
|
+
queryClient.invalidateQueries({ queryKey: globalQueryKey, ...filters, stale: true }, invalidateOptions)
|
|
150
|
+
|
|
151
|
+
queryClient.isFetching(globalQueryKey)
|
|
152
|
+
queryClient.isFetching(globalQueryKey, filters)
|
|
153
|
+
queryClient.isFetching(globalQueryKey, { queryKey: ['todos'], type: 'all', exact: true })
|
|
154
|
+
queryClient.isFetching(globalQueryKey, { queryKey: ['todos'], ...filters })
|
|
155
|
+
queryClient.isFetching({ queryKey: globalQueryKey, ...filters, stale: true })
|
|
156
|
+
// Stays as it is because the code couldn't infer the type of the "queryKeysFromAnotherModule" identifier.
|
|
157
|
+
queryClient.isFetching(queryKeysFromAnotherModule)
|
|
158
|
+
|
|
159
|
+
queryClient.refetchQueries(queryKey)
|
|
160
|
+
queryClient.refetchQueries(queryKey, filters)
|
|
161
|
+
queryClient.refetchQueries(queryKey, filters, refetchOptions)
|
|
162
|
+
queryClient.refetchQueries(queryKey, { queryKey: ['todos'], ...filters }, { ...refetchOptions, cancelRefetch: true })
|
|
163
|
+
queryClient.refetchQueries({ queryKey: queryKey, ...filters })
|
|
164
|
+
queryClient.refetchQueries({ queryKey: queryKey, ...filters }, { ...refetchOptions, cancelRefetch: true })
|
|
165
|
+
// Stays as it is because the code couldn't infer the type of the "queryKeysFromAnotherModule" identifier.
|
|
166
|
+
queryClient.refetchQueries(queryKeysFromAnotherModule)
|
|
167
|
+
queryClient.refetchQueries(queryKeysFromAnotherModule, filters)
|
|
168
|
+
queryClient.refetchQueries(queryKeysFromAnotherModule, filters, refetchOptions)
|
|
169
|
+
|
|
170
|
+
queryClient.removeQueries(queryKey)
|
|
171
|
+
queryClient.removeQueries(queryKey, filters)
|
|
172
|
+
queryClient.removeQueries(queryKey, { queryKey: ['todos'], ...filters, stale: true })
|
|
173
|
+
queryClient.removeQueries({ queryKey, ...filters, stale: true })
|
|
174
|
+
// Stays as it is because the code couldn't infer the type of the "queryKeysFromAnotherModule" identifier.
|
|
175
|
+
queryClient.removeQueries(queryKeysFromAnotherModule)
|
|
176
|
+
queryClient.removeQueries(queryKeysFromAnotherModule, filters)
|
|
177
|
+
|
|
178
|
+
queryClient.resetQueries(queryKey)
|
|
179
|
+
queryClient.resetQueries(queryKey, filters)
|
|
180
|
+
queryClient.resetQueries(queryKey, filters, resetOptions)
|
|
181
|
+
queryClient.resetQueries(queryKey, { queryKey: ['todos'], ...filters, stale: true })
|
|
182
|
+
queryClient.resetQueries(queryKey, { queryKey: ['todos'], ...filters, stale: true }, resetOptions)
|
|
183
|
+
queryClient.resetQueries({ queryKey, ...filters, stale: true })
|
|
184
|
+
queryClient.resetQueries({ queryKey, ...filters, stale: true }, resetOptions)
|
|
185
|
+
// Stays as it is because the code couldn't infer the type of the "queryKeysFromAnotherModule" identifier.
|
|
186
|
+
queryClient.resetQueries(queryKeysFromAnotherModule)
|
|
187
|
+
queryClient.resetQueries(queryKeysFromAnotherModule, filters)
|
|
188
|
+
queryClient.resetQueries(queryKeysFromAnotherModule, filters, resetOptions)
|
|
189
|
+
|
|
190
|
+
queryClient.fetchQuery(queryKey)
|
|
191
|
+
queryClient.fetchQuery(queryKey, fetchOptions)
|
|
192
|
+
queryClient.fetchQuery(queryKey, { networkMode: 'always', ...fetchOptions })
|
|
193
|
+
queryClient.fetchQuery(queryKey, queryFn, fetchOptions)
|
|
194
|
+
queryClient.fetchQuery(queryKey, () => 'data', { networkMode: 'always', ...fetchOptions })
|
|
195
|
+
// Stays as it is because the code couldn't infer the type of the "queryKeysFromAnotherModule" identifier.
|
|
196
|
+
queryClient.fetchQuery(queryKeysFromAnotherModule)
|
|
197
|
+
queryClient.fetchQuery(queryKeysFromAnotherModule, fetchOptions)
|
|
198
|
+
queryClient.fetchQuery(queryKeysFromAnotherModule, queryFn, fetchOptions)
|
|
199
|
+
}
|