@@ -5,11 +5,10 @@ import type {
5
5
QueryArgFrom ,
6
6
ResultTypeFrom ,
7
7
} from '../endpointDefinitions'
8
- import { DefinitionType } from '../endpointDefinitions'
8
+ import { DefinitionType , isQueryDefinition } from '../endpointDefinitions'
9
9
import type { QueryThunk , MutationThunk , QueryThunkArg } from './buildThunks'
10
10
import type { AnyAction , ThunkAction , SerializedError } from '@reduxjs/toolkit'
11
11
import type { SubscriptionOptions , RootState } from './apiState'
12
- import { QueryStatus } from './apiState'
13
12
import type { InternalSerializeQueryArgs } from '../defaultSerializeQueryArgs'
14
13
import type { Api , ApiContext } from '../apiTypes'
15
14
import type { ApiEndpointQuery } from './module'
@@ -279,10 +278,21 @@ Features like automatic cache collection, automatic refetching etc. will not be
279
278
endpointDefinition,
280
279
endpointName,
281
280
} )
281
+
282
+ const endpointContext = context . endpointDefinitions [ endpointName ]
283
+ const sideEffectForced =
284
+ isQueryDefinition ( endpointContext ) &&
285
+ endpointContext . sideEffectForced ?.( {
286
+ getState,
287
+ endpointState : (
288
+ api . endpoints [ endpointName ] as ApiEndpointQuery < any , any >
289
+ ) . select ( arg ) ( getState ( ) ) ,
290
+ } )
291
+
282
292
const thunk = queryThunk ( {
283
293
type : 'query' ,
284
294
subscribe,
285
- forceRefetch,
295
+ forceRefetch : forceRefetch || sideEffectForced ,
286
296
subscriptionOptions,
287
297
endpointName,
288
298
originalArgs : arg ,
0 commit comments