@trpc/react-query 10.28.0 → 10.28.2

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.
Files changed (70) hide show
  1. package/README.md +1 -2
  2. package/dist/{context-1da55110.js → context-4557b3d3.js} +31 -31
  3. package/dist/{createHooksInternal-bd7db1e7.js → createHooksInternal-03506f75.js} +483 -472
  4. package/dist/{createHooksInternal-9f8a4b21.js → createHooksInternal-466f5861.js} +21 -7
  5. package/dist/{createHooksInternal-d15d0073.mjs → createHooksInternal-a6562110.mjs} +21 -7
  6. package/dist/createTRPCReact.d.ts +75 -75
  7. package/dist/createTRPCReact.d.ts.map +1 -1
  8. package/dist/index.d.ts +5 -5
  9. package/dist/index.js +1 -1
  10. package/dist/index.mjs +2 -2
  11. package/dist/internals/context.d.ts +125 -127
  12. package/dist/internals/context.d.ts.map +1 -1
  13. package/dist/internals/getArrayQueryKey.d.ts +24 -24
  14. package/dist/internals/getArrayQueryKey.d.ts.map +1 -1
  15. package/dist/internals/getClientArgs.d.ts +1 -1
  16. package/dist/internals/getQueryKey.d.ts +30 -30
  17. package/dist/internals/getQueryKey.d.ts.map +1 -1
  18. package/dist/internals/useHookResult.d.ts +9 -9
  19. package/dist/internals/useQueries.d.ts +27 -27
  20. package/dist/internals/useQueries.d.ts.map +1 -1
  21. package/dist/interop.d.ts +10 -10
  22. package/dist/interop.d.ts.map +1 -1
  23. package/dist/{queryClient-77734cc3.js → queryClient-1c8d7d8a.js} +3 -3
  24. package/dist/server/index.d.ts +3 -3
  25. package/dist/server/ssgProxy.d.ts +36 -36
  26. package/dist/server/ssgProxy.d.ts.map +1 -1
  27. package/dist/server/types.d.ts +9 -9
  28. package/dist/server/types.d.ts.map +1 -1
  29. package/dist/shared/hooks/createHooksInternal.d.ts +27 -27
  30. package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
  31. package/dist/shared/hooks/createRootHooks.d.ts +6 -6
  32. package/dist/shared/hooks/deprecated/createHooksInternal.d.ts +60 -60
  33. package/dist/shared/hooks/deprecated/createHooksInternal.d.ts.map +1 -1
  34. package/dist/shared/hooks/types.d.ts +81 -81
  35. package/dist/shared/hooks/types.d.ts.map +1 -1
  36. package/dist/shared/index.d.ts +21 -21
  37. package/dist/shared/index.js +1 -1
  38. package/dist/shared/index.mjs +1 -1
  39. package/dist/shared/polymorphism/index.d.ts +4 -4
  40. package/dist/shared/polymorphism/mutationLike.d.ts +17 -17
  41. package/dist/shared/polymorphism/mutationLike.d.ts.map +1 -1
  42. package/dist/shared/polymorphism/queryLike.d.ts +17 -17
  43. package/dist/shared/polymorphism/queryLike.d.ts.map +1 -1
  44. package/dist/shared/polymorphism/routerLike.d.ts +9 -9
  45. package/dist/shared/polymorphism/routerLike.d.ts.map +1 -1
  46. package/dist/shared/polymorphism/utilsLike.d.ts +6 -6
  47. package/dist/shared/polymorphism/utilsLike.d.ts.map +1 -1
  48. package/dist/shared/proxy/decorationProxy.d.ts +7 -7
  49. package/dist/shared/proxy/useQueriesProxy.d.ts +17 -17
  50. package/dist/shared/proxy/useQueriesProxy.d.ts.map +1 -1
  51. package/dist/shared/proxy/utilsProxy.d.ts +92 -93
  52. package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
  53. package/dist/shared/queryClient.d.ts +15 -15
  54. package/dist/shared/queryClient.d.ts.map +1 -1
  55. package/dist/shared/types.d.ts +52 -52
  56. package/dist/ssg/index.d.ts +14 -14
  57. package/dist/ssg/ssg.d.ts +15 -15
  58. package/dist/ssg/ssg.d.ts.map +1 -1
  59. package/dist/utils/inferReactQueryProcedure.d.ts +23 -23
  60. package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
  61. package/package.json +7 -7
  62. package/src/createTRPCReact.tsx +3 -3
  63. package/src/internals/context.tsx +3 -5
  64. package/src/internals/getQueryKey.ts +2 -2
  65. package/src/interop.ts +2 -2
  66. package/src/server/ssgProxy.ts +2 -2
  67. package/src/shared/hooks/createHooksInternal.tsx +38 -13
  68. package/src/shared/hooks/deprecated/createHooksInternal.tsx +10 -7
  69. package/src/shared/proxy/utilsProxy.ts +4 -4
  70. package/src/ssg/ssg.ts +2 -2
package/README.md CHANGED
@@ -48,9 +48,8 @@ Use the provider to connect to your API.
48
48
 
49
49
  ```ts
50
50
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
51
- import React from 'react';
52
- import { useState } from 'react';
53
51
  import { trpc } from '~/utils/trpc';
52
+ import React, { useState } from 'react';
54
53
 
55
54
  export function App() {
56
55
  const [queryClient] = useState(() => new QueryClient());
@@ -1,38 +1,38 @@
1
1
  import { createContext } from 'react';
2
2
 
3
- /**
4
- * To allow easy interactions with groups of related queries, such as
5
- * invalidating all queries of a router, we use an array as the path when
6
- * storing in tanstack query. This function converts from the `.` separated
7
- * path passed around internally by both the legacy and proxy implementation.
8
- * https://github.com/trpc/trpc/issues/2611
9
- **/
10
- function getArrayQueryKey(queryKey, type) {
11
- const queryKeyArrayed = Array.isArray(queryKey) ? queryKey : [queryKey];
12
- const [path, input] = queryKeyArrayed;
13
- const arrayPath = typeof path !== 'string' || path === '' ? [] : path.split('.');
14
- // Construct a query key that is easy to destructure and flexible for
15
- // partial selecting etc.
16
- // https://github.com/trpc/trpc/issues/3128
17
- if (!input && (!type || type === 'any'))
18
- // for `utils.invalidate()` to match all queries (including vanilla react-query)
19
- // we don't want nested array if path is empty, i.e. `[]` instead of `[[]]`
20
- return arrayPath.length ? [arrayPath] : [];
21
- return [
22
- arrayPath,
23
- {
24
- ...(typeof input !== 'undefined' && { input: input }),
25
- ...(type && type !== 'any' && { type: type }),
26
- },
27
- ];
3
+ /**
4
+ * To allow easy interactions with groups of related queries, such as
5
+ * invalidating all queries of a router, we use an array as the path when
6
+ * storing in tanstack query. This function converts from the `.` separated
7
+ * path passed around internally by both the legacy and proxy implementation.
8
+ * https://github.com/trpc/trpc/issues/2611
9
+ **/
10
+ function getArrayQueryKey(queryKey, type) {
11
+ const queryKeyArrayed = Array.isArray(queryKey) ? queryKey : [queryKey];
12
+ const [path, input] = queryKeyArrayed;
13
+ const arrayPath = typeof path !== 'string' || path === '' ? [] : path.split('.');
14
+ // Construct a query key that is easy to destructure and flexible for
15
+ // partial selecting etc.
16
+ // https://github.com/trpc/trpc/issues/3128
17
+ if (!input && (!type || type === 'any'))
18
+ // for `utils.invalidate()` to match all queries (including vanilla react-query)
19
+ // we don't want nested array if path is empty, i.e. `[]` instead of `[[]]`
20
+ return arrayPath.length ? [arrayPath] : [];
21
+ return [
22
+ arrayPath,
23
+ {
24
+ ...(typeof input !== 'undefined' && { input: input }),
25
+ ...(type && type !== 'any' && { type: type }),
26
+ },
27
+ ];
28
28
  }
29
29
 
30
- const contextProps = [
31
- 'client',
32
- 'ssrContext',
33
- 'ssrState',
34
- 'abortOnUnmount',
35
- ];
30
+ const contextProps = [
31
+ 'client',
32
+ 'ssrContext',
33
+ 'ssrState',
34
+ 'abortOnUnmount',
35
+ ];
36
36
  const TRPCContext = createContext(null);
37
37
 
38
38
  export { TRPCContext as T, contextProps as c, getArrayQueryKey as g };