@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.cjs +22 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -12
- package/dist/index.js.map +1 -1
- package/package.json +15 -4
package/dist/index.cjs
CHANGED
|
@@ -690,6 +690,24 @@ function resolveOperationOverrides(node, override) {
|
|
|
690
690
|
return override.find((ov) => matchesPattern(node, ov))?.options ?? {};
|
|
691
691
|
}
|
|
692
692
|
/**
|
|
693
|
+
* The request groups a query key is built from, matching `buildQueryKeyParams`. Headers are
|
|
694
|
+
* deliberately absent: they do not identify a cache entry, so the key factory takes no parameter
|
|
695
|
+
* for an operation that only carries headers.
|
|
696
|
+
*/
|
|
697
|
+
const queryKeyGroupOrder = [
|
|
698
|
+
"path",
|
|
699
|
+
"query",
|
|
700
|
+
"body"
|
|
701
|
+
];
|
|
702
|
+
/**
|
|
703
|
+
* Whether the generated query key factory declares a parameter, so a call site passes an argument
|
|
704
|
+
* only when one is accepted.
|
|
705
|
+
*/
|
|
706
|
+
function hasQueryKeyParams(node) {
|
|
707
|
+
const groups = getRequestGroups(node);
|
|
708
|
+
return queryKeyGroupOrder.some((key) => groups[key]);
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
693
711
|
* Build QueryKey params as the grouped `{ path, query, body }` object (NO headers, NO config),
|
|
694
712
|
* typed from the operation's `Options` minus `url`. The query key transformer reads the
|
|
695
713
|
* grouped `path`/`query`/`body` bindings.
|
|
@@ -698,11 +716,7 @@ function buildQueryKeyParams(node, options) {
|
|
|
698
716
|
const { resolver } = options;
|
|
699
717
|
const groupedParam = buildGroupedRequestParam(node, {
|
|
700
718
|
resolver,
|
|
701
|
-
keys:
|
|
702
|
-
"path",
|
|
703
|
-
"query",
|
|
704
|
-
"body"
|
|
705
|
-
]
|
|
719
|
+
keys: queryKeyGroupOrder
|
|
706
720
|
});
|
|
707
721
|
return (0, _kubb_plugin_ts.createFunctionParameters)({ params: groupedParam ? [groupedParam] : [] });
|
|
708
722
|
}
|
|
@@ -719,11 +733,7 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam,
|
|
|
719
733
|
});
|
|
720
734
|
const groupedKeyParam = buildGroupedRequestParam(node, {
|
|
721
735
|
resolver: tsResolver,
|
|
722
|
-
keys:
|
|
723
|
-
"path",
|
|
724
|
-
"query",
|
|
725
|
-
"body"
|
|
726
|
-
],
|
|
736
|
+
keys: queryKeyGroupOrder,
|
|
727
737
|
memberTypeWrapper
|
|
728
738
|
});
|
|
729
739
|
const queryKeyParamsNode = (0, _kubb_plugin_ts.createFunctionParameters)({ params: groupedKeyParam ? [groupedKeyParam] : [] });
|
|
@@ -1219,7 +1229,7 @@ function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
1219
1229
|
`TPageParam = ${pageParamType}`
|
|
1220
1230
|
];
|
|
1221
1231
|
const resolvedParams = buildResolvedRequestParams(node);
|
|
1222
|
-
const queryKeyArgs = resolvedParams ? "resolvedParams" : "";
|
|
1232
|
+
const queryKeyArgs = resolvedParams && hasQueryKeyParams(node) ? "resolvedParams" : "";
|
|
1223
1233
|
const queryOptionsArgs = resolvedParams ? "resolvedParams, config" : "config";
|
|
1224
1234
|
const paramsNode = buildInfiniteQueryParamsNode(node, {
|
|
1225
1235
|
resolver: tsResolver,
|
|
@@ -1408,7 +1418,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1408
1418
|
`TQueryKey extends QueryKey = ${queryKeyTypeName}`
|
|
1409
1419
|
];
|
|
1410
1420
|
const resolvedParams = buildResolvedRequestParams(node);
|
|
1411
|
-
const queryKeyArgs = resolvedParams ? "resolvedParams" : "";
|
|
1421
|
+
const queryKeyArgs = resolvedParams && hasQueryKeyParams(node) ? "resolvedParams" : "";
|
|
1412
1422
|
const queryOptionsArgs = resolvedParams ? "resolvedParams, config" : "config";
|
|
1413
1423
|
const paramsNode = buildQueryParamsNode(node, {
|
|
1414
1424
|
resolver: tsResolver,
|