@kubb/plugin-react-query 5.5.1 → 5.5.4
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/dist/index.cjs +29 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +564 -0
- package/dist/index.d.ts +29 -4
- package/dist/index.js +29 -4
- package/dist/index.js.map +1 -1
- package/docs/options.md +20 -4
- package/kubb-extension.json +1 -1
- package/package.json +14 -9
- package/dist/rolldown-runtime-C0LytTxp.js +0 -8
package/docs/options.md
CHANGED
|
@@ -12,9 +12,9 @@ Pass these options to `pluginReactQuery()`. Shared options link to [Shared plugi
|
|
|
12
12
|
| [`infinite`](#infinite) | Generate `useInfiniteQuery` hooks for pagination. | `false` |
|
|
13
13
|
| [`suspense`](#suspense) | Generate `useSuspenseQuery` hooks. | `false` |
|
|
14
14
|
| [`query`](#query) | Configure the query hooks. | `{ methods: ['GET', 'QUERY'], importPath: '@tanstack/react-query' }` |
|
|
15
|
-
| [`queryKey`](#querykey) | Build the `queryKey` for each query hook. |
|
|
15
|
+
| [`queryKey`](#querykey) | Build the `queryKey` for each query hook. | Exported `queryKeyTransformer` |
|
|
16
16
|
| [`mutation`](#mutation) | Configure the mutation hooks. | `{ methods: ['POST', 'PUT', 'PATCH', 'DELETE'], importPath: '@tanstack/react-query' }` |
|
|
17
|
-
| [`mutationKey`](#mutationkey) | Build the `mutationKey` for each mutation hook. |
|
|
17
|
+
| [`mutationKey`](#mutationkey) | Build the `mutationKey` for each mutation hook. | Exported `mutationKeyTransformer` |
|
|
18
18
|
| [`customOptions`](#customoptions) | Route every hook through your own options function. | None |
|
|
19
19
|
| [`hooks`](#hooks) | Emit `use*` hook functions on top of the factories. | `false` |
|
|
20
20
|
| [`include`](https://kubb.dev/docs/5.x/reference/plugin-options#include) | Keep only operations that match. | None |
|
|
@@ -190,7 +190,7 @@ Builds the `queryKey` for each hook from the operation `node`, `casing` and `var
|
|
|
190
190
|
| -------- | ------------------------------------------------------ |
|
|
191
191
|
| Type | `(props: { node, casing, variant }) => Array<unknown>` |
|
|
192
192
|
| Required | `false` |
|
|
193
|
-
| Default |
|
|
193
|
+
| Default | Exported `queryKeyTransformer` |
|
|
194
194
|
|
|
195
195
|
`variant` is `'query'`, `'suspenseQuery'`, `'infiniteQuery'` or `'suspenseInfiniteQuery'`. The default key adds `infinite: true` to infinite variants so they never share a cache entry with the plain query.
|
|
196
196
|
|
|
@@ -198,6 +198,14 @@ Builds the `queryKey` for each hook from the operation `node`, `casing` and `var
|
|
|
198
198
|
queryKey: ({ node, variant }) => [JSON.stringify({ variant, operationId: node.operationId })]
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
+
To extend the default key instead of replacing it, import `queryKeyTransformer` and spread its result. The default segments can change between releases, so spread them instead of reading single entries.
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { queryKeyTransformer } from '@kubb/plugin-react-query'
|
|
205
|
+
|
|
206
|
+
queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
207
|
+
```
|
|
208
|
+
|
|
201
209
|
### mutation
|
|
202
210
|
|
|
203
211
|
Which operations become mutations, emitting a `mutationOptions` factory by default. Set `false` to skip, or set [`hooks`](#hooks) to also emit `useMutation`.
|
|
@@ -236,7 +244,15 @@ Builds the `mutationKey` for each mutation hook, for batched invalidations or `u
|
|
|
236
244
|
| -------- | ------------------------------------------------------ |
|
|
237
245
|
| Type | `(props: { node, casing, variant }) => Array<unknown>` |
|
|
238
246
|
| Required | `false` |
|
|
239
|
-
| Default |
|
|
247
|
+
| Default | Exported `mutationKeyTransformer` |
|
|
248
|
+
|
|
249
|
+
Extend the default the same way with `mutationKeyTransformer`:
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
import { mutationKeyTransformer } from '@kubb/plugin-react-query'
|
|
253
|
+
|
|
254
|
+
mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
255
|
+
```
|
|
240
256
|
|
|
241
257
|
### customOptions
|
|
242
258
|
|
package/kubb-extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-react-query",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.4",
|
|
4
4
|
"description": "Generate type-safe TanStack Query (React Query) hooks with Kubb. Covers useQuery, useMutation, useInfiniteQuery, and queryOptions with full TypeScript support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-generation",
|
|
@@ -64,9 +64,14 @@
|
|
|
64
64
|
},
|
|
65
65
|
"exports": {
|
|
66
66
|
".": {
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
"import": {
|
|
68
|
+
"types": "./dist/index.d.ts",
|
|
69
|
+
"default": "./dist/index.js"
|
|
70
|
+
},
|
|
71
|
+
"require": {
|
|
72
|
+
"types": "./dist/index.d.cts",
|
|
73
|
+
"default": "./dist/index.cjs"
|
|
74
|
+
}
|
|
70
75
|
},
|
|
71
76
|
"./package.json": "./package.json",
|
|
72
77
|
"./kubb-extension.json": "./kubb-extension.json"
|
|
@@ -76,19 +81,19 @@
|
|
|
76
81
|
"registry": "https://registry.npmjs.org/"
|
|
77
82
|
},
|
|
78
83
|
"dependencies": {
|
|
79
|
-
"@kubb/plugin-ts": "^5.0.
|
|
84
|
+
"@kubb/plugin-ts": "^5.0.14"
|
|
80
85
|
},
|
|
81
86
|
"devDependencies": {
|
|
82
87
|
"@internals/client": "0.0.0",
|
|
83
88
|
"@internals/shared": "0.0.0",
|
|
84
89
|
"@internals/tanstack-query": "0.0.0",
|
|
85
90
|
"@internals/utils": "0.0.0",
|
|
86
|
-
"@tanstack/react-query": "^5.104.
|
|
87
|
-
"kubb": "^5.
|
|
91
|
+
"@tanstack/react-query": "^5.104.3",
|
|
92
|
+
"kubb": "^5.11.1"
|
|
88
93
|
},
|
|
89
94
|
"peerDependencies": {
|
|
90
95
|
"@tanstack/react-query": "^5.82.0",
|
|
91
|
-
"kubb": "^5.
|
|
96
|
+
"kubb": "^5.11.1"
|
|
92
97
|
},
|
|
93
98
|
"peerDependenciesMeta": {
|
|
94
99
|
"@tanstack/react-query": {
|
|
@@ -96,7 +101,7 @@
|
|
|
96
101
|
}
|
|
97
102
|
},
|
|
98
103
|
"engines": {
|
|
99
|
-
"node": ">=22"
|
|
104
|
+
"node": ">=22.12"
|
|
100
105
|
},
|
|
101
106
|
"scripts": {
|
|
102
107
|
"build": "tsdown",
|