@tanstack/solid-query 5.0.0-alpha.52 → 5.0.0-alpha.54

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 (75) hide show
  1. package/build/{stats-html.html → stats.html} +1 -1
  2. package/package.json +6 -10
  3. package/build/source/QueryClient.js +0 -6
  4. package/build/source/QueryClientProvider.jsx +0 -21
  5. package/build/source/__tests__/QueryClientProvider.test.jsx +0 -120
  6. package/build/source/__tests__/createInfiniteQuery.test.jsx +0 -1360
  7. package/build/source/__tests__/createMutation.test.jsx +0 -867
  8. package/build/source/__tests__/createQueries.test.jsx +0 -590
  9. package/build/source/__tests__/createQuery.test.jsx +0 -4398
  10. package/build/source/__tests__/createQuery.types.test.jsx +0 -153
  11. package/build/source/__tests__/suspense.test.jsx +0 -659
  12. package/build/source/__tests__/transition.test.jsx +0 -42
  13. package/build/source/__tests__/useIsFetching.test.jsx +0 -190
  14. package/build/source/__tests__/useIsMutating.test.jsx +0 -196
  15. package/build/source/__tests__/utils.jsx +0 -50
  16. package/build/source/createBaseQuery.js +0 -173
  17. package/build/source/createInfiniteQuery.js +0 -8
  18. package/build/source/createMutation.js +0 -38
  19. package/build/source/createQueries.js +0 -38
  20. package/build/source/createQuery.js +0 -9
  21. package/build/source/index.js +0 -15
  22. package/build/source/setBatchUpdatesFn.js +0 -3
  23. package/build/source/types.js +0 -2
  24. package/build/source/useIsFetching.js +0 -12
  25. package/build/source/useIsMutating.js +0 -12
  26. package/build/source/utils.js +0 -7
  27. package/build/stats.json +0 -605
  28. /package/build/{types → lib}/QueryClient.d.ts +0 -0
  29. /package/build/{types → lib}/QueryClient.d.ts.map +0 -0
  30. /package/build/{types → lib}/QueryClientProvider.d.ts +0 -0
  31. /package/build/{types → lib}/QueryClientProvider.d.ts.map +0 -0
  32. /package/build/{types → lib}/__tests__/QueryClientProvider.test.d.ts +0 -0
  33. /package/build/{types → lib}/__tests__/QueryClientProvider.test.d.ts.map +0 -0
  34. /package/build/{types → lib}/__tests__/createInfiniteQuery.test.d.ts +0 -0
  35. /package/build/{types → lib}/__tests__/createInfiniteQuery.test.d.ts.map +0 -0
  36. /package/build/{types → lib}/__tests__/createMutation.test.d.ts +0 -0
  37. /package/build/{types → lib}/__tests__/createMutation.test.d.ts.map +0 -0
  38. /package/build/{types → lib}/__tests__/createQueries.test.d.ts +0 -0
  39. /package/build/{types → lib}/__tests__/createQueries.test.d.ts.map +0 -0
  40. /package/build/{types → lib}/__tests__/createQuery.test.d.ts +0 -0
  41. /package/build/{types → lib}/__tests__/createQuery.test.d.ts.map +0 -0
  42. /package/build/{types → lib}/__tests__/createQuery.types.test.d.ts +0 -0
  43. /package/build/{types → lib}/__tests__/createQuery.types.test.d.ts.map +0 -0
  44. /package/build/{types → lib}/__tests__/suspense.test.d.ts +0 -0
  45. /package/build/{types → lib}/__tests__/suspense.test.d.ts.map +0 -0
  46. /package/build/{types → lib}/__tests__/transition.test.d.ts +0 -0
  47. /package/build/{types → lib}/__tests__/transition.test.d.ts.map +0 -0
  48. /package/build/{types → lib}/__tests__/useIsFetching.test.d.ts +0 -0
  49. /package/build/{types → lib}/__tests__/useIsFetching.test.d.ts.map +0 -0
  50. /package/build/{types → lib}/__tests__/useIsMutating.test.d.ts +0 -0
  51. /package/build/{types → lib}/__tests__/useIsMutating.test.d.ts.map +0 -0
  52. /package/build/{types → lib}/__tests__/utils.d.ts +0 -0
  53. /package/build/{types → lib}/__tests__/utils.d.ts.map +0 -0
  54. /package/build/{types → lib}/createBaseQuery.d.ts +0 -0
  55. /package/build/{types → lib}/createBaseQuery.d.ts.map +0 -0
  56. /package/build/{types → lib}/createInfiniteQuery.d.ts +0 -0
  57. /package/build/{types → lib}/createInfiniteQuery.d.ts.map +0 -0
  58. /package/build/{types → lib}/createMutation.d.ts +0 -0
  59. /package/build/{types → lib}/createMutation.d.ts.map +0 -0
  60. /package/build/{types → lib}/createQueries.d.ts +0 -0
  61. /package/build/{types → lib}/createQueries.d.ts.map +0 -0
  62. /package/build/{types → lib}/createQuery.d.ts +0 -0
  63. /package/build/{types → lib}/createQuery.d.ts.map +0 -0
  64. /package/build/{types → lib}/index.d.ts +0 -0
  65. /package/build/{types → lib}/index.d.ts.map +0 -0
  66. /package/build/{types → lib}/setBatchUpdatesFn.d.ts +0 -0
  67. /package/build/{types → lib}/setBatchUpdatesFn.d.ts.map +0 -0
  68. /package/build/{types → lib}/types.d.ts +0 -0
  69. /package/build/{types → lib}/types.d.ts.map +0 -0
  70. /package/build/{types → lib}/useIsFetching.d.ts +0 -0
  71. /package/build/{types → lib}/useIsFetching.d.ts.map +0 -0
  72. /package/build/{types → lib}/useIsMutating.d.ts +0 -0
  73. /package/build/{types → lib}/useIsMutating.d.ts.map +0 -0
  74. /package/build/{types → lib}/utils.d.ts +0 -0
  75. /package/build/{types → lib}/utils.d.ts.map +0 -0
@@ -6157,7 +6157,7 @@ var drawChart = (function (exports) {
6157
6157
  </script>
6158
6158
  <script>
6159
6159
  /*<!--*/
6160
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.cjs","children":[{"name":"src/index.ts","uid":"efc3-3"}]},{"name":"setBatchUpdatesFn.cjs","children":[{"name":"src/setBatchUpdatesFn.ts","uid":"efc3-7"}]},{"name":"QueryClient.cjs","children":[{"name":"src/QueryClient.ts","uid":"efc3-11"}]},{"name":"createQuery.cjs","children":[{"name":"src/createQuery.ts","uid":"efc3-15"}]},{"name":"QueryClientProvider.cjs","children":[{"name":"src/QueryClientProvider.tsx","uid":"efc3-19"}]},{"name":"useIsFetching.cjs","children":[{"name":"src/useIsFetching.ts","uid":"efc3-23"}]},{"name":"createInfiniteQuery.cjs","children":[{"name":"src/createInfiniteQuery.ts","uid":"efc3-27"}]},{"name":"createMutation.cjs","children":[{"name":"src/createMutation.ts","uid":"efc3-31"}]},{"name":"useIsMutating.cjs","children":[{"name":"src/useIsMutating.ts","uid":"efc3-35"}]},{"name":"createQueries.cjs","children":[{"name":"src/createQueries.ts","uid":"efc3-39"}]},{"name":"createBaseQuery.cjs","children":[{"name":"src/createBaseQuery.ts","uid":"efc3-43"}]},{"name":"utils.cjs","children":[{"name":"src/utils.ts","uid":"efc3-52"}]}],"isRoot":true},"nodeParts":{"efc3-3":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"efc3-2"},"efc3-7":{"renderedLength":62,"gzipLength":76,"brotliLength":0,"metaUid":"efc3-6"},"efc3-11":{"renderedLength":103,"gzipLength":98,"brotliLength":0,"metaUid":"efc3-10"},"efc3-15":{"renderedLength":216,"gzipLength":142,"brotliLength":0,"metaUid":"efc3-14"},"efc3-19":{"renderedLength":651,"gzipLength":285,"brotliLength":0,"metaUid":"efc3-18"},"efc3-23":{"renderedLength":466,"gzipLength":232,"brotliLength":0,"metaUid":"efc3-22"},"efc3-27":{"renderedLength":260,"gzipLength":184,"brotliLength":0,"metaUid":"efc3-26"},"efc3-31":{"renderedLength":1019,"gzipLength":461,"brotliLength":0,"metaUid":"efc3-30"},"efc3-35":{"renderedLength":488,"gzipLength":235,"brotliLength":0,"metaUid":"efc3-34"},"efc3-39":{"renderedLength":1695,"gzipLength":655,"brotliLength":0,"metaUid":"efc3-38"},"efc3-43":{"renderedLength":6696,"gzipLength":2270,"brotliLength":0,"metaUid":"efc3-42"},"efc3-52":{"renderedLength":234,"gzipLength":163,"brotliLength":0,"metaUid":"efc3-51"}},"nodeMetas":{"efc3-2":{"id":"/src/index.ts","moduleParts":{"index.cjs":"efc3-3"},"imported":[{"uid":"efc3-6"},{"uid":"efc3-53"},{"uid":"efc3-54"},{"uid":"efc3-10"},{"uid":"efc3-14"},{"uid":"efc3-18"},{"uid":"efc3-22"},{"uid":"efc3-26"},{"uid":"efc3-30"},{"uid":"efc3-34"},{"uid":"efc3-38"}],"importedBy":[],"isEntry":true},"efc3-6":{"id":"/src/setBatchUpdatesFn.ts","moduleParts":{"setBatchUpdatesFn.cjs":"efc3-7"},"imported":[{"uid":"efc3-53"},{"uid":"efc3-55"}],"importedBy":[{"uid":"efc3-2"}]},"efc3-10":{"id":"/src/QueryClient.ts","moduleParts":{"QueryClient.cjs":"efc3-11"},"imported":[{"uid":"efc3-53"}],"importedBy":[{"uid":"efc3-2"}]},"efc3-14":{"id":"/src/createQuery.ts","moduleParts":{"createQuery.cjs":"efc3-15"},"imported":[{"uid":"efc3-53"},{"uid":"efc3-55"},{"uid":"efc3-42"}],"importedBy":[{"uid":"efc3-2"}]},"efc3-18":{"id":"/src/QueryClientProvider.tsx","moduleParts":{"QueryClientProvider.cjs":"efc3-19"},"imported":[{"uid":"efc3-56"},{"uid":"efc3-55"}],"importedBy":[{"uid":"efc3-2"},{"uid":"efc3-22"},{"uid":"efc3-30"},{"uid":"efc3-34"},{"uid":"efc3-38"},{"uid":"efc3-42"}]},"efc3-22":{"id":"/src/useIsFetching.ts","moduleParts":{"useIsFetching.cjs":"efc3-23"},"imported":[{"uid":"efc3-55"},{"uid":"efc3-18"}],"importedBy":[{"uid":"efc3-2"}]},"efc3-26":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"createInfiniteQuery.cjs":"efc3-27"},"imported":[{"uid":"efc3-53"},{"uid":"efc3-42"},{"uid":"efc3-55"}],"importedBy":[{"uid":"efc3-2"}]},"efc3-30":{"id":"/src/createMutation.ts","moduleParts":{"createMutation.cjs":"efc3-31"},"imported":[{"uid":"efc3-53"},{"uid":"efc3-18"},{"uid":"efc3-55"},{"uid":"efc3-57"},{"uid":"efc3-51"}],"importedBy":[{"uid":"efc3-2"}]},"efc3-34":{"id":"/src/useIsMutating.ts","moduleParts":{"useIsMutating.cjs":"efc3-35"},"imported":[{"uid":"efc3-18"},{"uid":"efc3-55"}],"importedBy":[{"uid":"efc3-2"}]},"efc3-38":{"id":"/src/createQueries.ts","moduleParts":{"createQueries.cjs":"efc3-39"},"imported":[{"uid":"efc3-53"},{"uid":"efc3-55"},{"uid":"efc3-57"},{"uid":"efc3-18"}],"importedBy":[{"uid":"efc3-2"}]},"efc3-42":{"id":"/src/createBaseQuery.ts","moduleParts":{"createBaseQuery.cjs":"efc3-43"},"imported":[{"uid":"efc3-53"},{"uid":"efc3-56"},{"uid":"efc3-55"},{"uid":"efc3-57"},{"uid":"efc3-18"},{"uid":"efc3-51"}],"importedBy":[{"uid":"efc3-14"},{"uid":"efc3-26"}]},"efc3-51":{"id":"/src/utils.ts","moduleParts":{"utils.cjs":"efc3-52"},"imported":[],"importedBy":[{"uid":"efc3-30"},{"uid":"efc3-42"}]},"efc3-53":{"id":"@tanstack/query-core","moduleParts":{},"imported":[],"importedBy":[{"uid":"efc3-2"},{"uid":"efc3-6"},{"uid":"efc3-10"},{"uid":"efc3-14"},{"uid":"efc3-26"},{"uid":"efc3-30"},{"uid":"efc3-38"},{"uid":"efc3-42"}],"isExternal":true},"efc3-54":{"id":"/src/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"efc3-2"}]},"efc3-55":{"id":"solid-js","moduleParts":{},"imported":[],"importedBy":[{"uid":"efc3-6"},{"uid":"efc3-14"},{"uid":"efc3-18"},{"uid":"efc3-22"},{"uid":"efc3-26"},{"uid":"efc3-30"},{"uid":"efc3-34"},{"uid":"efc3-38"},{"uid":"efc3-42"}],"isExternal":true},"efc3-56":{"id":"solid-js/web","moduleParts":{},"imported":[],"importedBy":[{"uid":"efc3-18"},{"uid":"efc3-42"}],"isExternal":true},"efc3-57":{"id":"solid-js/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"efc3-30"},{"uid":"efc3-38"},{"uid":"efc3-42"}],"isExternal":true}},"env":{"rollup":"3.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
6160
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.cjs","children":[{"name":"src/index.ts","uid":"6b71-3"}]},{"name":"setBatchUpdatesFn.cjs","children":[{"name":"src/setBatchUpdatesFn.ts","uid":"6b71-7"}]},{"name":"QueryClient.cjs","children":[{"name":"src/QueryClient.ts","uid":"6b71-11"}]},{"name":"createQuery.cjs","children":[{"name":"src/createQuery.ts","uid":"6b71-15"}]},{"name":"QueryClientProvider.cjs","children":[{"name":"src/QueryClientProvider.tsx","uid":"6b71-19"}]},{"name":"useIsFetching.cjs","children":[{"name":"src/useIsFetching.ts","uid":"6b71-23"}]},{"name":"createInfiniteQuery.cjs","children":[{"name":"src/createInfiniteQuery.ts","uid":"6b71-27"}]},{"name":"createMutation.cjs","children":[{"name":"src/createMutation.ts","uid":"6b71-31"}]},{"name":"useIsMutating.cjs","children":[{"name":"src/useIsMutating.ts","uid":"6b71-35"}]},{"name":"createQueries.cjs","children":[{"name":"src/createQueries.ts","uid":"6b71-39"}]},{"name":"createBaseQuery.cjs","children":[{"name":"src/createBaseQuery.ts","uid":"6b71-43"}]},{"name":"utils.cjs","children":[{"name":"src/utils.ts","uid":"6b71-52"}]}],"isRoot":true},"nodeParts":{"6b71-3":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"6b71-2"},"6b71-7":{"renderedLength":62,"gzipLength":76,"brotliLength":0,"metaUid":"6b71-6"},"6b71-11":{"renderedLength":103,"gzipLength":98,"brotliLength":0,"metaUid":"6b71-10"},"6b71-15":{"renderedLength":216,"gzipLength":142,"brotliLength":0,"metaUid":"6b71-14"},"6b71-19":{"renderedLength":651,"gzipLength":285,"brotliLength":0,"metaUid":"6b71-18"},"6b71-23":{"renderedLength":466,"gzipLength":232,"brotliLength":0,"metaUid":"6b71-22"},"6b71-27":{"renderedLength":260,"gzipLength":184,"brotliLength":0,"metaUid":"6b71-26"},"6b71-31":{"renderedLength":1019,"gzipLength":461,"brotliLength":0,"metaUid":"6b71-30"},"6b71-35":{"renderedLength":488,"gzipLength":235,"brotliLength":0,"metaUid":"6b71-34"},"6b71-39":{"renderedLength":1695,"gzipLength":655,"brotliLength":0,"metaUid":"6b71-38"},"6b71-43":{"renderedLength":6696,"gzipLength":2270,"brotliLength":0,"metaUid":"6b71-42"},"6b71-52":{"renderedLength":234,"gzipLength":163,"brotliLength":0,"metaUid":"6b71-51"}},"nodeMetas":{"6b71-2":{"id":"/src/index.ts","moduleParts":{"index.cjs":"6b71-3"},"imported":[{"uid":"6b71-6"},{"uid":"6b71-53"},{"uid":"6b71-54"},{"uid":"6b71-10"},{"uid":"6b71-14"},{"uid":"6b71-18"},{"uid":"6b71-22"},{"uid":"6b71-26"},{"uid":"6b71-30"},{"uid":"6b71-34"},{"uid":"6b71-38"}],"importedBy":[],"isEntry":true},"6b71-6":{"id":"/src/setBatchUpdatesFn.ts","moduleParts":{"setBatchUpdatesFn.cjs":"6b71-7"},"imported":[{"uid":"6b71-53"},{"uid":"6b71-55"}],"importedBy":[{"uid":"6b71-2"}]},"6b71-10":{"id":"/src/QueryClient.ts","moduleParts":{"QueryClient.cjs":"6b71-11"},"imported":[{"uid":"6b71-53"}],"importedBy":[{"uid":"6b71-2"}]},"6b71-14":{"id":"/src/createQuery.ts","moduleParts":{"createQuery.cjs":"6b71-15"},"imported":[{"uid":"6b71-53"},{"uid":"6b71-55"},{"uid":"6b71-42"}],"importedBy":[{"uid":"6b71-2"}]},"6b71-18":{"id":"/src/QueryClientProvider.tsx","moduleParts":{"QueryClientProvider.cjs":"6b71-19"},"imported":[{"uid":"6b71-56"},{"uid":"6b71-55"}],"importedBy":[{"uid":"6b71-2"},{"uid":"6b71-22"},{"uid":"6b71-30"},{"uid":"6b71-34"},{"uid":"6b71-38"},{"uid":"6b71-42"}]},"6b71-22":{"id":"/src/useIsFetching.ts","moduleParts":{"useIsFetching.cjs":"6b71-23"},"imported":[{"uid":"6b71-55"},{"uid":"6b71-18"}],"importedBy":[{"uid":"6b71-2"}]},"6b71-26":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"createInfiniteQuery.cjs":"6b71-27"},"imported":[{"uid":"6b71-53"},{"uid":"6b71-42"},{"uid":"6b71-55"}],"importedBy":[{"uid":"6b71-2"}]},"6b71-30":{"id":"/src/createMutation.ts","moduleParts":{"createMutation.cjs":"6b71-31"},"imported":[{"uid":"6b71-53"},{"uid":"6b71-18"},{"uid":"6b71-55"},{"uid":"6b71-57"},{"uid":"6b71-51"}],"importedBy":[{"uid":"6b71-2"}]},"6b71-34":{"id":"/src/useIsMutating.ts","moduleParts":{"useIsMutating.cjs":"6b71-35"},"imported":[{"uid":"6b71-18"},{"uid":"6b71-55"}],"importedBy":[{"uid":"6b71-2"}]},"6b71-38":{"id":"/src/createQueries.ts","moduleParts":{"createQueries.cjs":"6b71-39"},"imported":[{"uid":"6b71-53"},{"uid":"6b71-55"},{"uid":"6b71-57"},{"uid":"6b71-18"}],"importedBy":[{"uid":"6b71-2"}]},"6b71-42":{"id":"/src/createBaseQuery.ts","moduleParts":{"createBaseQuery.cjs":"6b71-43"},"imported":[{"uid":"6b71-53"},{"uid":"6b71-56"},{"uid":"6b71-55"},{"uid":"6b71-57"},{"uid":"6b71-18"},{"uid":"6b71-51"}],"importedBy":[{"uid":"6b71-14"},{"uid":"6b71-26"}]},"6b71-51":{"id":"/src/utils.ts","moduleParts":{"utils.cjs":"6b71-52"},"imported":[],"importedBy":[{"uid":"6b71-30"},{"uid":"6b71-42"}]},"6b71-53":{"id":"@tanstack/query-core","moduleParts":{},"imported":[],"importedBy":[{"uid":"6b71-2"},{"uid":"6b71-6"},{"uid":"6b71-10"},{"uid":"6b71-14"},{"uid":"6b71-26"},{"uid":"6b71-30"},{"uid":"6b71-38"},{"uid":"6b71-42"}],"isExternal":true},"6b71-54":{"id":"/src/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"6b71-2"}]},"6b71-55":{"id":"solid-js","moduleParts":{},"imported":[],"importedBy":[{"uid":"6b71-6"},{"uid":"6b71-14"},{"uid":"6b71-18"},{"uid":"6b71-22"},{"uid":"6b71-26"},{"uid":"6b71-30"},{"uid":"6b71-34"},{"uid":"6b71-38"},{"uid":"6b71-42"}],"isExternal":true},"6b71-56":{"id":"solid-js/web","moduleParts":{},"imported":[],"importedBy":[{"uid":"6b71-18"},{"uid":"6b71-42"}],"isExternal":true},"6b71-57":{"id":"solid-js/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"6b71-30"},{"uid":"6b71-38"},{"uid":"6b71-42"}],"isExternal":true}},"env":{"rollup":"3.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
6161
6161
 
6162
6162
  const run = () => {
6163
6163
  const width = window.innerWidth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query",
3
- "version": "5.0.0-alpha.52",
3
+ "version": "5.0.0-alpha.54",
4
4
  "description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -11,20 +11,15 @@
11
11
  "url": "https://github.com/sponsors/tannerlinsley"
12
12
  },
13
13
  "type": "module",
14
- "types": "build/types/index.d.ts",
14
+ "types": "build/lib/index.d.ts",
15
15
  "main": "build/lib/index.cjs",
16
16
  "module": "build/lib/index.js",
17
17
  "exports": {
18
18
  ".": {
19
- "types": "./build/types/index.d.ts",
20
- "solid": "./build/source/index.js",
19
+ "types": "./build/lib/index.d.ts",
20
+ "solid": "./build/lib/index.js",
21
21
  "import": "./build/lib/index.js",
22
- "browser": {
23
- "import": "./build/lib/index.js",
24
- "require": "./build/lib/index.cjs"
25
- },
26
22
  "require": "./build/lib/index.cjs",
27
- "node": "./build/lib/index.cjs",
28
23
  "default": "./build/lib/index.cjs"
29
24
  },
30
25
  "./package.json": "./package.json"
@@ -51,8 +46,9 @@
51
46
  "test:types": "tsc --noEmit",
52
47
  "test:lib": "vitest run --coverage",
53
48
  "test:lib:dev": "pnpm run test:lib --watch",
49
+ "test:build": "publint",
54
50
  "build": "pnpm build:rollup && pnpm build:types",
55
51
  "build:rollup": "rollup --config rollup.config.js",
56
- "build:types": "tsc"
52
+ "build:types": "tsc --emitDeclarationOnly"
57
53
  }
58
54
  }
@@ -1,6 +0,0 @@
1
- import { QueryClient as QueryCoreClient } from '@tanstack/query-core';
2
- export class QueryClient extends QueryCoreClient {
3
- constructor(config = {}) {
4
- super(config);
5
- }
6
- }
@@ -1,21 +0,0 @@
1
- import { createContext, useContext, onMount, onCleanup } from 'solid-js';
2
- export const QueryClientContext = createContext(undefined);
3
- export const useQueryClient = (queryClient) => {
4
- const client = useContext(QueryClientContext);
5
- if (queryClient) {
6
- return queryClient;
7
- }
8
- if (!client) {
9
- throw new Error('No QueryClient set, use QueryClientProvider to set one');
10
- }
11
- return client;
12
- };
13
- export const QueryClientProvider = (props) => {
14
- onMount(() => {
15
- props.client.mount();
16
- });
17
- onCleanup(() => props.client.unmount());
18
- return (<QueryClientContext.Provider value={props.client}>
19
- {props.children}
20
- </QueryClientContext.Provider>);
21
- };
@@ -1,120 +0,0 @@
1
- import { render, screen, waitFor } from '@solidjs/testing-library';
2
- import { createQueryClient, sleep, queryKey } from './utils';
3
- import { QueryCache } from '@tanstack/query-core';
4
- import { createQuery, QueryClientProvider, useQueryClient } from '..';
5
- import { vi } from 'vitest';
6
- describe('QueryClientProvider', () => {
7
- it('sets a specific cache for all queries to use', async () => {
8
- const key = queryKey();
9
- const queryCache = new QueryCache();
10
- const queryClient = createQueryClient({ queryCache });
11
- function Page() {
12
- const query = createQuery(() => ({
13
- queryKey: key,
14
- queryFn: async () => {
15
- await sleep(10);
16
- return 'test';
17
- },
18
- }));
19
- return (<div>
20
- <h1>{query.data}</h1>
21
- </div>);
22
- }
23
- render(() => (<QueryClientProvider client={queryClient}>
24
- <Page />
25
- </QueryClientProvider>));
26
- await waitFor(() => {
27
- return screen.getByText('test');
28
- });
29
- expect(queryCache.find({ queryKey: key })).toBeDefined();
30
- });
31
- it('allows multiple caches to be partitioned', async () => {
32
- const key1 = queryKey();
33
- const key2 = queryKey();
34
- const queryCache1 = new QueryCache();
35
- const queryCache2 = new QueryCache();
36
- const queryClient1 = createQueryClient({ queryCache: queryCache1 });
37
- const queryClient2 = createQueryClient({ queryCache: queryCache2 });
38
- function Page1() {
39
- const query = createQuery(() => ({
40
- queryKey: key1,
41
- queryFn: async () => {
42
- await sleep(10);
43
- return 'test1';
44
- },
45
- }));
46
- return (<div>
47
- <h1>{query.data}</h1>
48
- </div>);
49
- }
50
- function Page2() {
51
- const query = createQuery(() => ({
52
- queryKey: key2,
53
- queryFn: async () => {
54
- await sleep(10);
55
- return 'test2';
56
- },
57
- }));
58
- return (<div>
59
- <h1>{query.data}</h1>
60
- </div>);
61
- }
62
- render(() => (<>
63
- <QueryClientProvider client={queryClient1}>
64
- <Page1 />
65
- </QueryClientProvider>
66
- <QueryClientProvider client={queryClient2}>
67
- <Page2 />
68
- </QueryClientProvider>
69
- </>));
70
- await waitFor(() => screen.getByText('test1'));
71
- await waitFor(() => screen.getByText('test2'));
72
- expect(queryCache1.find({ queryKey: key1 })).toBeDefined();
73
- expect(queryCache1.find({ queryKey: key2 })).not.toBeDefined();
74
- expect(queryCache2.find({ queryKey: key1 })).not.toBeDefined();
75
- expect(queryCache2.find({ queryKey: key2 })).toBeDefined();
76
- });
77
- it("uses defaultOptions for queries when they don't provide their own config", async () => {
78
- const key = queryKey();
79
- const queryCache = new QueryCache();
80
- const queryClient = createQueryClient({
81
- queryCache,
82
- defaultOptions: {
83
- queries: {
84
- gcTime: Infinity,
85
- },
86
- },
87
- });
88
- function Page() {
89
- const query = createQuery(() => ({
90
- queryKey: key,
91
- queryFn: async () => {
92
- await sleep(10);
93
- return 'test';
94
- },
95
- }));
96
- return (<div>
97
- <h1>{query.data}</h1>
98
- </div>);
99
- }
100
- render(() => (<QueryClientProvider client={queryClient}>
101
- <Page />
102
- </QueryClientProvider>));
103
- await waitFor(() => screen.getByText('test'));
104
- expect(queryCache.find({ queryKey: key })).toBeDefined();
105
- expect(queryCache.find({ queryKey: key })?.options.gcTime).toBe(Infinity);
106
- });
107
- describe('useQueryClient', () => {
108
- it('should throw an error if no query client has been set', () => {
109
- const consoleMock = vi
110
- .spyOn(console, 'error')
111
- .mockImplementation(() => undefined);
112
- function Page() {
113
- useQueryClient();
114
- return null;
115
- }
116
- expect(() => render(() => <Page />)).toThrow('No QueryClient set, use QueryClientProvider to set one');
117
- consoleMock.mockRestore();
118
- });
119
- });
120
- });