Skip to content

Commit a3ced0f

Browse files
committed
Pass through infinite query options
1 parent 5ec2430 commit a3ced0f

File tree

3 files changed

+55
-35
lines changed

3 files changed

+55
-35
lines changed

packages/toolkit/src/query/core/buildMiddleware/cacheLifecycle.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,12 @@ export type CacheLifecycleQueryExtraOptions<
143143
}
144144

145145
// copying QueryDefinition to get past initial build
146-
interface InfiniteQueryExtraOptions<
147-
TagTypes extends string,
146+
export type CacheLifecycleInfiniteQueryExtraOptions<
148147
ResultType,
149148
QueryArg,
150149
BaseQuery extends BaseQueryFn,
151150
ReducerPath extends string = string,
152-
> {
151+
> = {
153152
onCacheEntryAdded?(
154153
arg: QueryArg,
155154
api: QueryCacheLifecycleApi<QueryArg, BaseQuery, ResultType, ReducerPath>,

packages/toolkit/src/query/core/buildMiddleware/queryLifecycle.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,12 @@ export type QueryLifecycleQueryExtraOptions<
117117
}
118118

119119
// temporarily cloned QueryOptions again to just get the definition to build for now
120-
interface InfiniteQueryExtraOptions<
121-
TagTypes extends string,
120+
export type QueryLifecycleInfiniteQueryExtraOptions<
122121
ResultType,
123122
QueryArg,
124123
BaseQuery extends BaseQueryFn,
125124
ReducerPath extends string = string,
126-
> {
125+
> = {
127126
onQueryStarted?(
128127
arg: QueryArg,
129128
api: QueryLifecycleApi<QueryArg, BaseQuery, ResultType, ReducerPath>,

packages/toolkit/src/query/endpointDefinitions.ts

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import type {
1616
} from './baseQueryTypes'
1717
import type { CacheCollectionQueryExtraOptions } from './core/buildMiddleware/cacheCollection'
1818
import type {
19+
CacheLifecycleInfiniteQueryExtraOptions,
1920
CacheLifecycleMutationExtraOptions,
2021
CacheLifecycleQueryExtraOptions,
2122
} from './core/buildMiddleware/cacheLifecycle'
2223
import type {
24+
QueryLifecycleInfiniteQueryExtraOptions,
2325
QueryLifecycleMutationExtraOptions,
2426
QueryLifecycleQueryExtraOptions,
2527
} from './core/buildMiddleware/queryLifecycle'
@@ -265,13 +267,15 @@ type QueryTypes<
265267
* const useMyWrappedHook: UseQuery<typeof api.endpoints.query.Types.QueryDefinition> = ...
266268
* ```
267269
*/
268-
QueryDefinition: QueryDefinition<
269-
QueryArg,
270-
BaseQuery,
271-
TagTypes,
272-
ResultType,
273-
ReducerPath
274-
> | InfiniteQueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>
270+
QueryDefinition:
271+
| QueryDefinition<QueryArg, BaseQuery, TagTypes, ResultType, ReducerPath>
272+
| InfiniteQueryDefinition<
273+
QueryArg,
274+
BaseQuery,
275+
TagTypes,
276+
ResultType,
277+
ReducerPath
278+
>
275279
TagTypes: TagTypes
276280
ReducerPath: ReducerPath
277281
}
@@ -573,7 +577,19 @@ export interface InfiniteQueryExtraOptions<
573577
QueryArg,
574578
BaseQuery extends BaseQueryFn,
575579
ReducerPath extends string = string,
576-
> {
580+
> extends CacheLifecycleInfiniteQueryExtraOptions<
581+
ResultType,
582+
QueryArg,
583+
BaseQuery,
584+
ReducerPath
585+
>,
586+
QueryLifecycleInfiniteQueryExtraOptions<
587+
ResultType,
588+
QueryArg,
589+
BaseQuery,
590+
ReducerPath
591+
>,
592+
CacheCollectionQueryExtraOptions {
577593
type: DefinitionType.infinitequery
578594

579595
providesTags?: never
@@ -959,14 +975,20 @@ export type OverrideResultType<Definition, NewResultType> =
959975
ReducerPath
960976
>
961977
: Definition extends InfiniteQueryDefinition<
962-
infer QueryArg,
963-
infer BaseQuery,
964-
infer TagTypes,
965-
any,
966-
infer ReducerPath
967-
>
968-
? InfiniteQueryDefinition<QueryArg, BaseQuery, TagTypes, NewResultType, ReducerPath>
969-
: never
978+
infer QueryArg,
979+
infer BaseQuery,
980+
infer TagTypes,
981+
any,
982+
infer ReducerPath
983+
>
984+
? InfiniteQueryDefinition<
985+
QueryArg,
986+
BaseQuery,
987+
TagTypes,
988+
NewResultType,
989+
ReducerPath
990+
>
991+
: never
970992

971993
export type UpdateDefinitions<
972994
Definitions extends EndpointDefinitions,
@@ -1002,18 +1024,18 @@ export type UpdateDefinitions<
10021024
ReducerPath
10031025
>
10041026
: Definitions[K] extends InfiniteQueryDefinition<
1005-
infer QueryArg,
1006-
infer BaseQuery,
1007-
any,
1008-
infer ResultType,
1009-
infer ReducerPath
1010-
>
1011-
? InfiniteQueryDefinition<
1012-
QueryArg,
1013-
BaseQuery,
1014-
NewTagTypes,
1015-
TransformedResponse<NewDefinitions, K, ResultType>,
1016-
ReducerPath
1017-
>
1027+
infer QueryArg,
1028+
infer BaseQuery,
1029+
any,
1030+
infer ResultType,
1031+
infer ReducerPath
1032+
>
1033+
? InfiniteQueryDefinition<
1034+
QueryArg,
1035+
BaseQuery,
1036+
NewTagTypes,
1037+
TransformedResponse<NewDefinitions, K, ResultType>,
1038+
ReducerPath
1039+
>
10181040
: never
10191041
}

0 commit comments

Comments
 (0)