@kubb/plugin-react-query 5.5.3 → 5.5.5

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/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. | Built-in `queryKeyTransformer` |
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. | Built-in `mutationKeyTransformer` |
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 | Built-in `queryKeyTransformer` |
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 | Built-in `mutationKeyTransformer` |
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
 
@@ -220,6 +220,34 @@
220
220
  "description": "Module specifier the generated mutation hook imports from",
221
221
  "type": "text",
222
222
  "default": "@tanstack/react-query"
223
+ },
224
+ {
225
+ "key": "customOptionsImportPath",
226
+ "path": ["customOptions", "importPath"],
227
+ "label": "Custom Options Import Path",
228
+ "description": "Module of your hook that adds options to every generated query and mutation",
229
+ "type": "text"
230
+ },
231
+ {
232
+ "key": "customOptionsName",
233
+ "path": ["customOptions", "name"],
234
+ "label": "Custom Options Name",
235
+ "description": "Exported name of that hook, useCustomHookOptions when empty. Needs the import path",
236
+ "type": "text"
237
+ },
238
+ {
239
+ "key": "banner",
240
+ "path": ["output", "banner"],
241
+ "label": "Banner",
242
+ "description": "Text added at the top of every generated file",
243
+ "type": "text"
244
+ },
245
+ {
246
+ "key": "footer",
247
+ "path": ["output", "footer"],
248
+ "label": "Footer",
249
+ "description": "Text added at the end of every generated file",
250
+ "type": "text"
223
251
  }
224
252
  ]
225
253
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-react-query",
3
- "version": "5.5.3",
3
+ "version": "5.5.5",
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",
@@ -81,19 +81,19 @@
81
81
  "registry": "https://registry.npmjs.org/"
82
82
  },
83
83
  "dependencies": {
84
- "@kubb/plugin-ts": "^5.0.14"
84
+ "@kubb/plugin-ts": "^5.0.15"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@internals/client": "0.0.0",
88
88
  "@internals/shared": "0.0.0",
89
89
  "@internals/tanstack-query": "0.0.0",
90
90
  "@internals/utils": "0.0.0",
91
- "@tanstack/react-query": "^5.104.2",
92
- "kubb": "^5.10.3"
91
+ "@tanstack/react-query": "^5.104.4",
92
+ "kubb": "^5.12.5"
93
93
  },
94
94
  "peerDependencies": {
95
95
  "@tanstack/react-query": "^5.82.0",
96
- "kubb": "^5.10.3"
96
+ "kubb": "^5.12.5"
97
97
  },
98
98
  "peerDependenciesMeta": {
99
99
  "@tanstack/react-query": {