You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/openapi-ts/migrating.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,16 @@ This config option is deprecated and will be removed.
29
29
30
30
## v0.75.0
31
31
32
+
### Updated TanStack Query options
33
+
34
+
The TanStack Query plugin options have been expanded to support more naming and casing patterns. As a result, the following options have been renamed.
35
+
36
+
-`queryOptionsNameBuilder` renamed to `queryOptions`
37
+
-`infiniteQueryOptionsNameBuilder` renamed to `infiniteQueryOptions`
38
+
-`mutationOptionsNameBuilder` renamed to `mutationOptions`
39
+
-`queryKeyNameBuilder` renamed to `queryKeys`
40
+
-`infiniteQueryKeyNameBuilder` renamed to `infiniteQueryKeys`
41
+
32
42
### Added `plugin.forEach()` method
33
43
34
44
This method replaces the `.subscribe()` method. Additionally, `.forEach()` is executed immediately, which means we don't need the `before` and `after` events – simply move your code before and after the `.forEach()` block.
You can customize query function names using `queryOptionsNameBuilder`.
114
+
You can customize the naming and casing pattern for query options functions using the `queryOptions.name` and `queryOptions.case` options.
115
+
116
+
## Query Keys
117
+
118
+
If you have access to the result of query options function, you can get the query key from the `queryKey` field.
119
+
120
+
```ts
121
+
const { queryKey } =getPetByIdOptions({
122
+
path: {
123
+
petId: 1,
124
+
},
125
+
});
126
+
```
127
+
128
+
Alternatively, you can access the same query key by calling query key functions. The generated query key functions follow the naming convention of SDK functions and by default append `QueryKey`, e.g. `getPetByIdQueryKey()`.
129
+
130
+
```ts
131
+
const queryKey =getPetByIdQueryKey({
132
+
path: {
133
+
petId: 1,
134
+
},
135
+
});
136
+
```
137
+
138
+
You can customize the naming and casing pattern for query key functions using the `queryKeys.name` and `queryKeys.case` options.
You can customize infinite query function names using `infiniteQueryOptionsNameBuilder`.
156
+
You can customize the naming and casing pattern for infinite query options functions using the `infiniteQueryOptions.name` and `infiniteQueryOptions.case` options.
143
157
144
-
## Mutations
158
+
## Infinite Query Keys
145
159
146
-
Mutations are generated from DELETE, PATCH, POST, and PUT endpoints. The generated mutation functions follow the naming convention of SDK functions and by default append `Mutation`, e.g. `addPetMutation()`.
160
+
If you have access to the result of infinite query options function, you can get the query key from the `queryKey` field.
147
161
148
162
```ts
149
-
const addPet =useMutation({
150
-
...addPetMutation(),
151
-
onError: (error) => {
152
-
console.log(error);
153
-
},
154
-
});
155
-
156
-
addPet.mutate({
157
-
body: {
158
-
name: 'Kitty',
163
+
const { queryKey } =getPetByIdInfiniteOptions({
164
+
path: {
165
+
petId: 1,
159
166
},
160
167
});
161
168
```
162
169
163
-
You can customize mutation function names using `mutationOptionsNameBuilder`.
164
-
165
-
## Query Keys
166
-
167
-
Query keys are generated for both queries and infinite queries. If you have access to the result of query or infinite query options function, you can get the query key from the `queryKey` field.
170
+
Alternatively, you can access the same query key by calling query key functions. The generated query key functions follow the naming convention of SDK functions and by default append `InfiniteQueryKey`, e.g. `getPetByIdInfiniteQueryKey()`.
168
171
169
172
```ts
170
-
const{ queryKey } =getPetByIdOptions({
173
+
const queryKey =getPetByIdInfiniteQueryKey({
171
174
path: {
172
175
petId: 1,
173
176
},
174
177
});
175
178
```
176
179
177
-
Alternatively, you can access the same query key by calling query key functions. The generated query key functions follow the naming convention of SDK functions and by default append `QueryKey` or `InfiniteQueryKey`, e.g. `getPetByIdQueryKey()` or `getPetByIdInfiniteQueryKey()`.
180
+
You can customize the naming and casing pattern for infinite query key functions using the `infiniteQueryKeys.name` and `infiniteQueryKeys.case` options.
181
+
182
+
## Mutations
183
+
184
+
Mutations are generated from DELETE, PATCH, POST, and PUT endpoints. The generated mutation functions follow the naming convention of SDK functions and by default append `Mutation`, e.g. `addPetMutation()`.
178
185
179
186
```ts
180
-
const queryKey =getPetByIdQueryKey({
181
-
path: {
182
-
petId: 1,
187
+
const addPet =useMutation({
188
+
...addPetMutation(),
189
+
onError: (error) => {
190
+
console.log(error);
191
+
},
192
+
});
193
+
194
+
addPet.mutate({
195
+
body: {
196
+
name: 'Kitty',
183
197
},
184
198
});
185
199
```
186
200
187
-
You can customize query key function names using `queryKeyNameBuilder` and `infiniteQueryKeyNameBuilder`.
201
+
You can customize the naming and casing pattern for mutation options functions using the `mutationOptions.name` and `mutationOptions.case` options.
0 commit comments