@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/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
 
@@ -20,7 +20,7 @@
20
20
  "dependencies": ["plugin-ts"],
21
21
  "compatibility": {
22
22
  "kubb": ">=5.8.3",
23
- "node": ">=22"
23
+ "node": ">=22.12"
24
24
  },
25
25
  "role": "consumer",
26
26
  "options": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-react-query",
3
- "version": "5.5.1",
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
- "types": "./dist/index.d.ts",
68
- "import": "./dist/index.js",
69
- "require": "./dist/index.cjs"
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.12"
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.2",
87
- "kubb": "^5.10.2"
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.10.2"
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",
@@ -1,8 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
- //#endregion
8
- export { __name as t };