@robohall/react-query-factory 2.1.1 → 2.1.2
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/README.md +8 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,7 +167,10 @@ const describeInstances = queryFactory({
|
|
|
167
167
|
queryKey: ['ec2:DescribeInstances'],
|
|
168
168
|
queryFn: (params: DescribeInstancesCommandInput, ctx) =>
|
|
169
169
|
ec2.send(
|
|
170
|
-
new DescribeInstancesCommand({
|
|
170
|
+
new DescribeInstancesCommand({
|
|
171
|
+
...params,
|
|
172
|
+
NextToken: ctx.pageParam ?? params.NextToken,
|
|
173
|
+
}),
|
|
171
174
|
{
|
|
172
175
|
abortSignal: ctx.signal,
|
|
173
176
|
},
|
|
@@ -179,7 +182,7 @@ const describeInstances = queryFactory({
|
|
|
179
182
|
...(page.Reservations?.flatMap(r => r.Instances ?? []) ?? []),
|
|
180
183
|
],
|
|
181
184
|
shouldFetchNextPage: (instances, opts: { minResults?: number }) =>
|
|
182
|
-
opts.minResults
|
|
185
|
+
opts.minResults != null && instances.length < opts.minResults,
|
|
183
186
|
});
|
|
184
187
|
|
|
185
188
|
// useQuery — crawls all pages, data is Instance[]
|
|
@@ -234,7 +237,7 @@ The `crawlOptions` argument passed at call time is forwarded to `shouldFetchNext
|
|
|
234
237
|
const describeInstances = queryFactory({
|
|
235
238
|
// ...
|
|
236
239
|
shouldFetchNextPage: (instances, opts: { minResults?: number }) =>
|
|
237
|
-
opts.minResults
|
|
240
|
+
opts.minResults != null && instances.length < opts.minResults,
|
|
238
241
|
});
|
|
239
242
|
|
|
240
243
|
// two separate cache entries — crawl independently
|
|
@@ -258,7 +261,7 @@ const describeInstances = queryFactory({
|
|
|
258
261
|
queryFn: (params: DescribeInstancesCommandInput) =>
|
|
259
262
|
paginateDescribeInstances({ client: ec2 }, params),
|
|
260
263
|
shouldFetchNextPage: (instances, opts: { minResults?: number }) =>
|
|
261
|
-
opts.minResults
|
|
264
|
+
opts.minResults != null && instances.length < opts.minResults,
|
|
262
265
|
reduce: (acc, page: DescribeInstancesResponse): Instance[] => [
|
|
263
266
|
...(acc ?? []),
|
|
264
267
|
...(page.Reservations?.flatMap(r => r.Instances ?? []) ?? []),
|
|
@@ -281,7 +284,7 @@ const describeInstances = queryFactory({
|
|
|
281
284
|
getNextPageParam: page => page.NextToken,
|
|
282
285
|
initialPageParam: undefined as string | undefined,
|
|
283
286
|
shouldFetchNextPage: (instances, opts: { minResults?: number }) =>
|
|
284
|
-
opts.minResults
|
|
287
|
+
opts.minResults != null && instances.length < opts.minResults,
|
|
285
288
|
reduce: (acc, page): Instance[] => [
|
|
286
289
|
...(acc ?? []),
|
|
287
290
|
...(page.Instances ?? []),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robohall/react-query-factory",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A factory abstraction for TanStack Query (React Query) with composable keys, crawling support, and automatic infinite query generation",
|
|
5
5
|
"author": "Robert Hall",
|
|
6
6
|
"license": "MIT",
|