Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions packages/toolkit/src/query/core/buildMiddleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import type {
FullTagDescription,
} from '../../endpointDefinitions'
import type { QueryStatus, QuerySubState, RootState } from '../apiState'
import type { QueryThunkArg } from '../buildThunks'
import { buildCacheCollectionHandler } from './cacheCollection'
import { buildInvalidationByTagsHandler } from './invalidationByTags'
import { buildPollingHandler } from './polling'
import type {
BuildMiddlewareInput,
BuildSubMiddlewareInput,
InternalHandlerBuilder,
InternalMiddlewareState,
} from './types'
Expand Down Expand Up @@ -63,7 +63,7 @@ export function buildMiddleware<
currentSubscriptions: {},
}

const builderArgs = {
const builderArgs: BuildSubMiddlewareInput = {
...(input as any as BuildMiddlewareInput<
EndpointDefinitions,
string,
Expand Down Expand Up @@ -135,17 +135,13 @@ export function buildMiddleware<
QuerySubState<any>,
{ status: QueryStatus.uninitialized }
>,
queryCacheKey: string,
override: Partial<QueryThunkArg> = {},
) {
return queryThunk({
type: 'query',
endpointName: querySubState.endpointName,
originalArgs: querySubState.originalArgs,
subscribe: false,
forceRefetch: true,
queryCacheKey: queryCacheKey as any,
...override,
})
return api.endpoints[querySubState.endpointName].initiate(
querySubState.originalArgs as never,
{
forceRefetch: true,
subscribe: false,
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const buildInvalidationByTagsHandler: InternalHandlerBuilder = ({
}),
)
} else if (querySubState.status !== QueryStatus.uninitialized) {
mwApi.dispatch(refetchQuery(querySubState, queryCacheKey))
mwApi.dispatch(refetchQuery(querySubState))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/core/buildMiddleware/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const buildPollingHandler: InternalHandlerBuilder = ({
pollingInterval: lowestPollingInterval,
timeout: setTimeout(() => {
if (state.config.focused || !skipPollingIfUnfocused) {
api.dispatch(refetchQuery(querySubState, queryCacheKey))
api.dispatch(refetchQuery(querySubState))
}
startNextPoll({ queryCacheKey }, api)
}, lowestPollingInterval),
Expand Down
6 changes: 2 additions & 4 deletions packages/toolkit/src/query/core/buildMiddleware/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type {
Action,
AsyncThunkAction,
Middleware,
MiddlewareAPI,
ThunkAction,
ThunkDispatch,
UnknownAction,
} from '@reduxjs/toolkit'
Expand Down Expand Up @@ -64,9 +64,7 @@ export interface BuildSubMiddlewareInput
QuerySubState<any>,
{ status: QueryStatus.uninitialized }
>,
queryCacheKey: string,
override?: Partial<QueryThunkArg>,
): AsyncThunkAction<ThunkResult, QueryThunkArg, {}>
): ThunkAction<unknown, unknown, unknown, UnknownAction>
isThisApiSliceAction: (action: Action) => boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const buildWindowEventHandler: InternalHandlerBuilder = ({
}),
)
} else if (querySubState.status !== QueryStatus.uninitialized) {
api.dispatch(refetchQuery(querySubState, queryCacheKey))
api.dispatch(refetchQuery(querySubState))
}
}
}
Expand Down