@kubb/plugin-react-query 5.0.0 → 5.0.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.js CHANGED
@@ -663,6 +663,24 @@ function resolveOperationOverrides(node, override) {
663
663
  return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
664
664
  }
665
665
  /**
666
+ * The request groups a query key is built from, matching `buildQueryKeyParams`. Headers are
667
+ * deliberately absent: they do not identify a cache entry, so the key factory takes no parameter
668
+ * for an operation that only carries headers.
669
+ */
670
+ const queryKeyGroupOrder = [
671
+ "path",
672
+ "query",
673
+ "body"
674
+ ];
675
+ /**
676
+ * Whether the generated query key factory declares a parameter, so a call site passes an argument
677
+ * only when one is accepted.
678
+ */
679
+ function hasQueryKeyParams(node) {
680
+ const groups = getRequestGroups(node);
681
+ return queryKeyGroupOrder.some((key) => groups[key]);
682
+ }
683
+ /**
666
684
  * Build QueryKey params as the grouped `{ path, query, body }` object (NO headers, NO config),
667
685
  * typed from the operation's `Options` minus `url`. The query key transformer reads the
668
686
  * grouped `path`/`query`/`body` bindings.
@@ -671,11 +689,7 @@ function buildQueryKeyParams(node, options) {
671
689
  const { resolver } = options;
672
690
  const groupedParam = buildGroupedRequestParam(node, {
673
691
  resolver,
674
- keys: [
675
- "path",
676
- "query",
677
- "body"
678
- ]
692
+ keys: queryKeyGroupOrder
679
693
  });
680
694
  return createFunctionParameters({ params: groupedParam ? [groupedParam] : [] });
681
695
  }
@@ -692,11 +706,7 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
692
706
  });
693
707
  const groupedKeyParam = buildGroupedRequestParam(node, {
694
708
  resolver: tsResolver,
695
- keys: [
696
- "path",
697
- "query",
698
- "body"
699
- ],
709
+ keys: queryKeyGroupOrder,
700
710
  memberTypeWrapper
701
711
  });
702
712
  const queryKeyParamsNode = createFunctionParameters({ params: groupedKeyParam ? [groupedKeyParam] : [] });
@@ -1192,7 +1202,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
1192
1202
  `TPageParam = ${pageParamType}`
1193
1203
  ];
1194
1204
  const resolvedParams = buildResolvedRequestParams(node);
1195
- const queryKeyArgs = resolvedParams ? "resolvedParams" : "";
1205
+ const queryKeyArgs = resolvedParams && hasQueryKeyParams(node) ? "resolvedParams" : "";
1196
1206
  const queryOptionsArgs = resolvedParams ? "resolvedParams, config" : "config";
1197
1207
  const paramsNode = buildInfiniteQueryParamsNode(node, {
1198
1208
  resolver: tsResolver,
@@ -1381,7 +1391,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
1381
1391
  `TQueryKey extends QueryKey = ${queryKeyTypeName}`
1382
1392
  ];
1383
1393
  const resolvedParams = buildResolvedRequestParams(node);
1384
- const queryKeyArgs = resolvedParams ? "resolvedParams" : "";
1394
+ const queryKeyArgs = resolvedParams && hasQueryKeyParams(node) ? "resolvedParams" : "";
1385
1395
  const queryOptionsArgs = resolvedParams ? "resolvedParams, config" : "config";
1386
1396
  const paramsNode = buildQueryParamsNode(node, {
1387
1397
  resolver: tsResolver,