@kubb/plugin-vue-query 5.9.0-canary.20261029T145027 → 5.9.1

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.d.cts CHANGED
@@ -315,6 +315,11 @@ type Options = OutputOptions & {
315
315
  * A client plugin must be registered. The composables always call its `<op>`.
316
316
  */
317
317
  client?: ClientSelector;
318
+ /**
319
+ * Shape of the value the hooks resolve to: `'data'` is the success body, `'full'` the client's whole `RequestResult` so a hook can read response headers. `'full'` needs a client plugin whose own `returnType` is `'full'` or `'plain'`.
320
+ * @default 'data'
321
+ */
322
+ returnType?: 'data' | 'full';
318
323
  /**
319
324
  * Skip operations matching at least one entry in the list.
320
325
  */
@@ -382,6 +387,7 @@ type ResolvedOptions = {
382
387
  * The resolved contract client the generators import and call.
383
388
  */
384
389
  client: ResolvedClient;
390
+ returnType?: 'data' | 'full';
385
391
  /**
386
392
  * Resolved infinite query configuration, or `false` when infinite queries are disabled.
387
393
  */
package/dist/index.d.ts CHANGED
@@ -315,6 +315,11 @@ type Options = OutputOptions & {
315
315
  * A client plugin must be registered. The composables always call its `<op>`.
316
316
  */
317
317
  client?: ClientSelector;
318
+ /**
319
+ * Shape of the value the hooks resolve to: `'data'` is the success body, `'full'` the client's whole `RequestResult` so a hook can read response headers. `'full'` needs a client plugin whose own `returnType` is `'full'` or `'plain'`.
320
+ * @default 'data'
321
+ */
322
+ returnType?: 'data' | 'full';
318
323
  /**
319
324
  * Skip operations matching at least one entry in the list.
320
325
  */
@@ -382,6 +387,7 @@ type ResolvedOptions = {
382
387
  * The resolved contract client the generators import and call.
383
388
  */
384
389
  client: ResolvedClient;
390
+ returnType?: 'data' | 'full';
385
391
  /**
386
392
  * Resolved infinite query configuration, or `false` when infinite queries are disabled.
387
393
  */
package/dist/index.js CHANGED
@@ -84,12 +84,18 @@ function getPrimarySuccessContentType(node) {
84
84
  return contentTypes[0].split(";")[0].trim().toLowerCase();
85
85
  }
86
86
  /**
87
- * Whether an operation streams its primary success response as Server-Sent Events
88
- * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a
89
- * one-shot `RequestResult`.
87
+ * The `text/event-stream` content of the primary success response, when it is the only content type. A response that also
88
+ * declares another type stays a normal call with its query hooks.
89
+ */
90
+ function getEventStreamContent(node) {
91
+ return getPrimarySuccessContentType(node) === "text/event-stream" ? getPrimarySuccessResponse(node)?.content?.[0] : void 0;
92
+ }
93
+ /**
94
+ * Whether an operation streams its primary success response as Server-Sent Events (`text/event-stream`). The client
95
+ * generator uses this to return a typed event stream instead of a one-shot `RequestResult`.
90
96
  */
91
97
  function isEventStream(node) {
92
- return getPrimarySuccessContentType(node) === "text/event-stream";
98
+ return getEventStreamContent(node) !== void 0;
93
99
  }
94
100
  const requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`;
95
101
  function buildRequestConfigType(node) {
@@ -157,6 +163,22 @@ function buildOperationComments(node, options = {}) {
157
163
  }
158
164
  const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
159
165
  /**
166
+ * An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter
167
+ * per property, typed and serialized like any other.
168
+ * Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.
169
+ */
170
+ function spreadQuerystring(param) {
171
+ const schema = param.schema.type === "ref" ? param.schema.schema : param.schema;
172
+ const formEncoded = !param.contentType || param.contentType.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded";
173
+ if (schema?.type !== "object" || !formEncoded) return [param];
174
+ return schema.properties.map((property) => ast.factory.createParameter({
175
+ name: property.name,
176
+ in: "query",
177
+ schema: property.schema,
178
+ required: param.required && property.required
179
+ }));
180
+ }
181
+ /**
160
182
  * Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each
161
183
  * group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance
162
184
  * (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the
@@ -165,17 +187,18 @@ const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
165
187
  function getOperationParameters(node) {
166
188
  const cached = operationParameterGroupsByNode.get(node);
167
189
  if (cached) return cached;
168
- const group = (location) => {
190
+ const dedupe = (params) => {
169
191
  const seen = /* @__PURE__ */ new Set();
170
- return node.parameters.filter((param) => {
171
- if (param.in !== location || seen.has(param.name)) return false;
192
+ return params.filter((param) => {
193
+ if (seen.has(param.name)) return false;
172
194
  seen.add(param.name);
173
195
  return true;
174
196
  });
175
197
  };
198
+ const group = (location) => dedupe(node.parameters.filter((param) => param.in === location));
176
199
  const groups = {
177
200
  path: group("path"),
178
- query: group("query"),
201
+ query: dedupe([...group("query"), ...group("querystring").flatMap(spreadQuerystring)]),
179
202
  header: group("header"),
180
203
  cookie: group("cookie")
181
204
  };
@@ -478,11 +501,11 @@ function createGroupConfig(group) {
478
501
  }
479
502
  // kubb-extension.json
480
503
  var compatibility = {
481
- "kubb": ">=5.14.6",
504
+ "kubb": ">=5.16.0",
482
505
  "node": ">=22.22"
483
506
  };
484
507
  // package.json
485
- var version = "5.9.0-canary.20261029T145027";
508
+ var version = "5.9.1";
486
509
  // ../../internals/client/src/resolveOperationTypes.ts
487
510
  /**
488
511
  * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
@@ -731,8 +754,16 @@ function resolveClientOperation(options) {
731
754
  * `pluginZod({ inferred: 'codec' })`), banner and footer.
732
755
  */
733
756
  function resolveHookFile(node, ctx, options) {
734
- const { name, output, group, contractOp, keyTypeName, extraTypeNames = [] } = options;
757
+ const { name, output, group, contractOp, keyTypeName, extraTypeNames = [], returnType = "data" } = options;
735
758
  const { config, root, resolver } = ctx;
759
+ if (returnType !== "data" && contractOp.returnType === "data") throw new Diagnostics.Error({
760
+ code: Diagnostics.code.invalidPluginOptions,
761
+ severity: "error",
762
+ message: `Option \`returnType\` is '${returnType}' for ${node.operationId}, but the client plugin has \`returnType: 'data'\` and only returns the response body.`,
763
+ help: "Set the client plugin's `returnType` to 'full', or set the hook plugin's `returnType` to 'data'.",
764
+ location: { kind: "config" },
765
+ plugin: resolver.pluginName
766
+ });
736
767
  const types = resolveOperationTypes(ctx.driver, resolver.pluginName);
737
768
  const tsResolver = types.resolver;
738
769
  const file = resolver.file({
@@ -751,9 +782,10 @@ function resolveHookFile(node, ctx, options) {
751
782
  });
752
783
  const importedTypeNames = [
753
784
  tsResolver.response.options(node),
785
+ tsResolver.response.responses(node),
754
786
  ...extraTypeNames,
755
787
  ...resolveOperationTypeNames(node, tsResolver, {
756
- exclude: keyTypeName ? [keyTypeName] : void 0,
788
+ exclude: [keyTypeName, returnType !== "data" ? tsResolver.response.response(node) : null].filter((name) => Boolean(name)),
757
789
  order: "body-response-first",
758
790
  includeParams: false
759
791
  })
@@ -768,6 +800,7 @@ function resolveHookFile(node, ctx, options) {
768
800
  tsResolver,
769
801
  contractOp,
770
802
  importedTypeNames,
803
+ returnType,
771
804
  banner: resolver.default.banner(ctx.meta, {
772
805
  output,
773
806
  config,
@@ -798,7 +831,11 @@ function HookFile({ hook, imports, children }) {
798
831
  path: contractOp.path
799
832
  }),
800
833
  /* @__PURE__ */ jsx(File.Import, {
801
- name: ["RequestConfig", "ResponseErrorConfig"],
834
+ name: [
835
+ "RequestConfig",
836
+ "ResponseErrorConfig",
837
+ "RequestResult"
838
+ ],
802
839
  root: contractOp.clientPathIsFile ? file.path : void 0,
803
840
  path: contractOp.clientPath,
804
841
  isTypeOnly: true
@@ -938,11 +975,12 @@ function buildClientCall(node, options) {
938
975
  }
939
976
  /**
940
977
  * Builds the query/mutation body that resolves a `buildClientCall` expression down to the bare
941
- * success body. `returnType` mirrors the registered client plugin's own `returnType` option: with
978
+ * success body. `clientReturnType` mirrors the registered client plugin's own `returnType` option: with
942
979
  * `'data'` the call already resolves to the bare body, so it is returned directly; with `'full'`
943
980
  * (the default) the call carries `unwrap()`, so the body calls it instead of destructuring `data`
944
981
  * off the full result by hand. With `'plain'` (plugin-client) the call resolves to the user's
945
- * `RequestResult`, so the body awaits it and reads `data`.
982
+ * `RequestResult`, so the body awaits it and reads `data`. With `returnType` `'full'` the body
983
+ * resolves to the whole `RequestResult`; `resolveHookFile` rejects that for a client that already stripped it.
946
984
  *
947
985
  * @example
948
986
  * ```ts
@@ -951,22 +989,24 @@ function buildClientCall(node, options) {
951
989
  * ```
952
990
  */
953
991
  function buildCallResultBody(call, options = {}) {
954
- const { returnType = "full" } = options;
955
- if (returnType === "data") return `return await ${call}`;
956
- if (returnType === "plain") return `return (await ${call}).data`;
992
+ const { clientReturnType = "full", returnType = "data" } = options;
993
+ if (returnType !== "data" || clientReturnType === "data") return `return ${call}`;
994
+ if (clientReturnType === "plain") return `return (await ${call}).data`;
957
995
  return `return ${call}.unwrap()`;
958
996
  }
959
997
  /**
960
998
  * Builds the `TData` / `TError` type expressions shared by every generated hook, joining the resolved
961
999
  * success responses into `TData` and wrapping the error responses in `ResponseErrorConfig<...>`.
1000
+ * With `returnType` `'full'`, `TData` is the client's `RequestResult` over the operation's responses record.
962
1001
  */
963
- function buildResponseTypes(node, resolver) {
964
- return resolver.memo(`responseTypes:${node.method}\0${node.path}`, () => {
1002
+ function buildResponseTypes(node, resolver, options = {}) {
1003
+ const { returnType = "data" } = options;
1004
+ return resolver.memo(`responseTypes:${returnType}:${node.method}\0${node.path}`, () => {
965
1005
  const successNames = resolveSuccessNames(node, resolver);
966
1006
  const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.response.response(node);
967
1007
  const errorNames = resolveErrorNames(node, resolver);
968
1008
  return {
969
- TData: responseName,
1009
+ TData: returnType !== "data" ? `RequestResult<${resolver.response.responses(node)}, true>` : responseName,
970
1010
  TError: `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`
971
1011
  };
972
1012
  });
@@ -1151,8 +1191,9 @@ function resolveMutationRequestType(node, resolver) {
1151
1191
  // ../../internals/tanstack-query/src/components/InfiniteQueryOptions.tsx
1152
1192
  const declarationPrinter$5 = functionPrinter({ mode: "declaration" });
1153
1193
  const callPrinter$3 = functionPrinter({ mode: "call" });
1154
- function InfiniteQueryOptions({ name, clientName, initialPageParam, hasExplicitInitialPageParam, cursorParam, nextParam, previousParam, getNextPageParam, getPreviousPageParam, node, tsResolver, queryParam, queryKeyName, queryKeyType = "typeof queryKey", memberTypeWrapper, unwrapName, returnType = "full" }) {
1155
- const { TData: queryFnDataType, TError: errorType } = buildResponseTypes(node, tsResolver);
1194
+ function InfiniteQueryOptions({ name, clientName, initialPageParam, hasExplicitInitialPageParam, cursorParam, nextParam, previousParam, getNextPageParam, getPreviousPageParam, node, tsResolver, queryParam, queryKeyName, queryKeyType = "typeof queryKey", memberTypeWrapper, unwrapName, clientReturnType, returnType }) {
1195
+ const { TData: queryFnDataType, TError: errorType } = buildResponseTypes(node, tsResolver, { returnType });
1196
+ const dataSuffix = returnType === "data" ? "" : ".data";
1156
1197
  const { queryParamsTypeName, pageParamType } = resolvePageParamType(node, {
1157
1198
  resolver: tsResolver,
1158
1199
  initialPageParam,
@@ -1174,21 +1215,24 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, hasExplicitI
1174
1215
  clientName,
1175
1216
  signal: true,
1176
1217
  unwrapName
1177
- }), { returnType });
1218
+ }), {
1219
+ clientReturnType,
1220
+ returnType
1221
+ });
1178
1222
  const initialPageParamLiteral = typeof initialPageParam === "string" || typeof initialPageParam === "object" && initialPageParam !== null ? JSON.stringify(initialPageParam) : String(initialPageParam === void 0 ? 0 : initialPageParam);
1179
1223
  const serializedGetNextPageParam = typeof getNextPageParam === "function" ? getNextPageParam.toString() : getNextPageParam;
1180
1224
  const getNextPageParamExpr = (() => {
1181
1225
  if (serializedGetNextPageParam) return `getNextPageParam: ${serializedGetNextPageParam}`;
1182
- if (nextParam) return `getNextPageParam: (lastPage) => ${getNestedAccessor(nextParam, "lastPage")}`;
1183
- if (cursorParam) return `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
1184
- return "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
1226
+ if (nextParam) return `getNextPageParam: (lastPage) => ${getNestedAccessor(nextParam, `lastPage${dataSuffix}`)}`;
1227
+ if (cursorParam) return `getNextPageParam: (lastPage) => lastPage${dataSuffix}['${cursorParam}']`;
1228
+ return `getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage${dataSuffix}) && lastPage${dataSuffix}.length === 0 ? undefined : lastPageParam + 1`;
1185
1229
  })();
1186
1230
  const serializedGetPreviousPageParam = typeof getPreviousPageParam === "function" ? getPreviousPageParam.toString() : getPreviousPageParam;
1187
1231
  const defaultPreviousThreshold = hasExplicitInitialPageParam ? initialPageParamLiteral : "1";
1188
1232
  const getPreviousPageParamExpr = (() => {
1189
1233
  if (serializedGetPreviousPageParam) return `getPreviousPageParam: ${serializedGetPreviousPageParam}`;
1190
- if (previousParam) return `getPreviousPageParam: (firstPage) => ${getNestedAccessor(previousParam, "firstPage")}`;
1191
- if (cursorParam) return `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
1234
+ if (previousParam) return `getPreviousPageParam: (firstPage) => ${getNestedAccessor(previousParam, `firstPage${dataSuffix}`)}`;
1235
+ if (cursorParam) return `getPreviousPageParam: (firstPage) => firstPage${dataSuffix}['${cursorParam}']`;
1192
1236
  if (serializedGetNextPageParam || nextParam) return null;
1193
1237
  return `getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= ${defaultPreviousThreshold} ? undefined : firstPageParam - 1`;
1194
1238
  })();
@@ -1411,8 +1455,8 @@ function getQueryOptionsParams(node, options) {
1411
1455
  memberTypeWrapper: maybeRefOrGetter
1412
1456
  });
1413
1457
  }
1414
- function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, returnType = "full" }) {
1415
- const { TData, TError } = buildResponseTypes(node, tsResolver);
1458
+ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, clientReturnType, returnType }) {
1459
+ const { TData, TError } = buildResponseTypes(node, tsResolver, { returnType });
1416
1460
  const queryKeyParamsNode = buildQueryKeyParams(node, {
1417
1461
  resolver: tsResolver,
1418
1462
  memberTypeWrapper: maybeRefOrGetter
@@ -1424,7 +1468,10 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, return
1424
1468
  clientName,
1425
1469
  signal: true,
1426
1470
  unwrapName: (name) => `toValue(${name})`
1427
- }), { returnType });
1471
+ }), {
1472
+ clientReturnType,
1473
+ returnType
1474
+ });
1428
1475
  return /* @__PURE__ */ jsx(File.Source, {
1429
1476
  name,
1430
1477
  isExportable: true,
@@ -1448,11 +1495,11 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, return
1448
1495
  // src/components/Query.tsx
1449
1496
  const declarationPrinter$1 = functionPrinter({ mode: "declaration" });
1450
1497
  const callPrinter$1 = functionPrinter({ mode: "call" });
1451
- function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, tsResolver, infinite }) {
1452
- const { TData, TError } = buildResponseTypes(node, tsResolver);
1498
+ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, tsResolver, infinite, returnType }) {
1499
+ const { TData, TError } = buildResponseTypes(node, tsResolver, { returnType });
1453
1500
  const optionsName = infinite ? "UseInfiniteQueryOptions" : "UseQueryOptions";
1454
1501
  const hookName = infinite ? "useInfiniteQuery" : "useQuery";
1455
- const returnType = `${infinite ? "UseInfiniteQueryReturnType" : "UseQueryReturnType"}<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
1502
+ const resultType = `${infinite ? "UseInfiniteQueryReturnType" : "UseQueryReturnType"}<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
1456
1503
  const generics = [
1457
1504
  infinite ? `TData = InfiniteData<${TData}>` : `TData = ${TData}`,
1458
1505
  `TQueryData = ${TData}`,
@@ -1519,7 +1566,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
1519
1566
  ...${queryOptionsName}(${queryOptionsParamsCall}),
1520
1567
  ...resolvedOptions,
1521
1568
  queryKey
1522
- } as unknown as ${optionsName}<${castGenerics.join(", ")}>, toValue(queryClient)) as ${returnType}
1569
+ } as unknown as ${optionsName}<${castGenerics.join(", ")}>, toValue(queryClient)) as ${resultType}
1523
1570
 
1524
1571
  queryResult.queryKey = queryKey as TQueryKey
1525
1572
 
@@ -1577,6 +1624,7 @@ const infiniteQueryGenerator = defineGenerator({
1577
1624
  output,
1578
1625
  group,
1579
1626
  contractOp,
1627
+ returnType: ctx.options.returnType,
1580
1628
  keyTypeName: queryKeyTypeName,
1581
1629
  extraTypeNames: [resolvePageParamType(node, {
1582
1630
  resolver: resolveOperationTypes(ctx.driver, ctx.resolver.pluginName).resolver,
@@ -1629,7 +1677,8 @@ const infiniteQueryGenerator = defineGenerator({
1629
1677
  initialPageParam: infiniteOptions.initialPageParam,
1630
1678
  hasExplicitInitialPageParam: infiniteOptions.hasExplicitInitialPageParam,
1631
1679
  queryParam: infiniteOptions.queryParam,
1632
- returnType: contractOp.returnType,
1680
+ clientReturnType: contractOp.returnType,
1681
+ returnType: hook.returnType,
1633
1682
  queryKeyType: "QueryKey",
1634
1683
  memberTypeWrapper: maybeRefOrGetter,
1635
1684
  unwrapName: (name) => `toValue(${name})`
@@ -1655,7 +1704,8 @@ const infiniteQueryGenerator = defineGenerator({
1655
1704
  queryKeyTypeName,
1656
1705
  node,
1657
1706
  tsResolver,
1658
- infinite: true
1707
+ infinite: true,
1708
+ returnType: hook.returnType
1659
1709
  })
1660
1710
  ]
1661
1711
  });
@@ -1665,8 +1715,8 @@ const infiniteQueryGenerator = defineGenerator({
1665
1715
  const declarationPrinter = functionPrinter({ mode: "declaration" });
1666
1716
  const callPrinter = functionPrinter({ mode: "call" });
1667
1717
  function buildMutationParamsNode(node, options) {
1668
- const { resolver } = options;
1669
- const { TData, TError } = buildResponseTypes(node, resolver);
1718
+ const { resolver, returnType } = options;
1719
+ const { TData, TError } = buildResponseTypes(node, resolver, { returnType });
1670
1720
  return buildHookParams(node, {
1671
1721
  resolver,
1672
1722
  withRequest: false,
@@ -1681,8 +1731,8 @@ function buildMutationParamsNode(node, options) {
1681
1731
  }`
1682
1732
  });
1683
1733
  }
1684
- function Mutation({ name, clientName, node, tsResolver, mutationKeyName, returnType = "full" }) {
1685
- const { TData, TError } = buildResponseTypes(node, tsResolver);
1734
+ function Mutation({ name, clientName, node, tsResolver, mutationKeyName, clientReturnType, returnType }) {
1735
+ const { TData, TError } = buildResponseTypes(node, tsResolver, { returnType });
1686
1736
  const groupedParam = buildGroupedRequestParam(node, {
1687
1737
  resolver: tsResolver,
1688
1738
  withContentType: true
@@ -1695,16 +1745,22 @@ function Mutation({ name, clientName, node, tsResolver, mutationKeyName, returnT
1695
1745
  clientName,
1696
1746
  signal: false,
1697
1747
  withContentType: true,
1698
- returnType,
1748
+ returnType: clientReturnType,
1699
1749
  unwrapName: (name) => `toValue<${TRequest}['${name}']>(${name})`
1700
- }), { returnType });
1750
+ }), {
1751
+ clientReturnType,
1752
+ returnType
1753
+ });
1701
1754
  const generics = [
1702
1755
  TData,
1703
1756
  TError,
1704
1757
  TRequest,
1705
1758
  "TContext"
1706
1759
  ].join(", ");
1707
- const paramsNode = buildMutationParamsNode(node, { resolver: tsResolver });
1760
+ const paramsNode = buildMutationParamsNode(node, {
1761
+ resolver: tsResolver,
1762
+ returnType
1763
+ });
1708
1764
  const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
1709
1765
  return /* @__PURE__ */ jsx(File.Source, {
1710
1766
  name,
@@ -1766,7 +1822,8 @@ const mutationGenerator = defineGenerator({
1766
1822
  name: mutationHookName,
1767
1823
  output,
1768
1824
  group,
1769
- contractOp
1825
+ contractOp,
1826
+ returnType: ctx.options.returnType
1770
1827
  });
1771
1828
  const groups = getRequestGroups(node);
1772
1829
  const hasRequestGroups = groups.path || groups.query || groups.body || groups.headers;
@@ -1800,7 +1857,8 @@ const mutationGenerator = defineGenerator({
1800
1857
  node,
1801
1858
  tsResolver: hook.tsResolver,
1802
1859
  mutationKeyName,
1803
- returnType: contractOp.returnType
1860
+ clientReturnType: contractOp.returnType,
1861
+ returnType: hook.returnType
1804
1862
  })
1805
1863
  ] })]
1806
1864
  });
@@ -1843,7 +1901,8 @@ const queryGenerator = defineGenerator({
1843
1901
  output,
1844
1902
  group,
1845
1903
  contractOp,
1846
- keyTypeName: queryKeyTypeName
1904
+ keyTypeName: queryKeyTypeName,
1905
+ returnType: ctx.options.returnType
1847
1906
  });
1848
1907
  const { tsResolver } = hook;
1849
1908
  return /* @__PURE__ */ jsxs(HookFile, {
@@ -1877,7 +1936,8 @@ const queryGenerator = defineGenerator({
1877
1936
  queryKeyName,
1878
1937
  node,
1879
1938
  tsResolver,
1880
- returnType: contractOp.returnType
1939
+ clientReturnType: contractOp.returnType,
1940
+ returnType: hook.returnType
1881
1941
  }),
1882
1942
  query && hooks && /* @__PURE__ */ jsxs(Fragment, { children: [
1883
1943
  /* @__PURE__ */ jsx(File.Import, {
@@ -1900,7 +1960,8 @@ const queryGenerator = defineGenerator({
1900
1960
  queryKeyName,
1901
1961
  queryKeyTypeName,
1902
1962
  node,
1903
- tsResolver
1963
+ tsResolver,
1964
+ returnType: hook.returnType
1904
1965
  })
1905
1966
  ] })
1906
1967
  ]
@@ -1975,7 +2036,7 @@ const pluginVueQuery = defineExtension({
1975
2036
  const { output = {
1976
2037
  path: "hooks",
1977
2038
  barrel: { type: "named" }
1978
- }, group, exclude = [], include, override = [], infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
2039
+ }, group, exclude = [], include, override = [], infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, hooks = false, client, returnType = "data", resolver: userResolver, macros: userMacros } = options;
1979
2040
  const resolver = userResolver ? Resolver.merge(resolverVueQuery, userResolver) : resolverVueQuery;
1980
2041
  setResolver(resolver);
1981
2042
  if (userMacros?.length) setMacros(userMacros);
@@ -1987,6 +2048,7 @@ const pluginVueQuery = defineExtension({
1987
2048
  client,
1988
2049
  plugins: useConfig().plugins
1989
2050
  }),
2051
+ returnType,
1990
2052
  queryKey,
1991
2053
  query: resolveQueryConfig(query, { importPath: "@tanstack/vue-query" }),
1992
2054
  mutationKey,