Skip to content

Commit 5d48471

Browse files
committed
Clarify endpointName
1 parent a7246a6 commit 5d48471

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

packages/toolkit/src/query/react/buildHooks.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
13761376
)
13771377
}
13781378

1379-
function buildQueryHooks(name: string): QueryHooks<any> {
1379+
function buildQueryHooks(endpointName: string): QueryHooks<any> {
13801380
const useQuerySubscription: UseQuerySubscription<any> = (
13811381
arg: any,
13821382
{
@@ -1388,7 +1388,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
13881388
skipPollingIfUnfocused = false,
13891389
} = {},
13901390
) => {
1391-
const { initiate } = api.endpoints[name] as ApiEndpointQuery<
1391+
const { initiate } = api.endpoints[endpointName] as ApiEndpointQuery<
13921392
QueryDefinition<any, any, any, any, any>,
13931393
Definitions
13941394
>
@@ -1430,8 +1430,8 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
14301430
// with a case where the query args did change but the serialization doesn't,
14311431
// and then we never try to initiate a refetch.
14321432
defaultSerializeQueryArgs,
1433-
context.endpointDefinitions[name],
1434-
name,
1433+
context.endpointDefinitions[endpointName],
1434+
endpointName,
14351435
)
14361436
const stableSubscriptionOptions = useShallowStableValue({
14371437
refetchOnReconnect,
@@ -1546,7 +1546,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
15461546
pollingInterval = 0,
15471547
skipPollingIfUnfocused = false,
15481548
} = {}) => {
1549-
const { initiate } = api.endpoints[name] as ApiEndpointQuery<
1549+
const { initiate } = api.endpoints[endpointName] as ApiEndpointQuery<
15501550
QueryDefinition<any, any, any, any, any>,
15511551
Definitions
15521552
>
@@ -1640,15 +1640,15 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
16401640
arg: any,
16411641
{ skip = false, selectFromResult } = {},
16421642
) => {
1643-
const { select } = api.endpoints[name] as ApiEndpointQuery<
1643+
const { select } = api.endpoints[endpointName] as ApiEndpointQuery<
16441644
QueryDefinition<any, any, any, any, any>,
16451645
Definitions
16461646
>
16471647
const stableArg = useStableQueryArgs(
16481648
skip ? skipToken : arg,
16491649
serializeQueryArgs,
1650-
context.endpointDefinitions[name],
1651-
name,
1650+
context.endpointDefinitions[endpointName],
1651+
endpointName,
16521652
)
16531653

16541654
type ApiRootState = Parameters<ReturnType<typeof select>>[0]
@@ -1740,7 +1740,9 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
17401740
}
17411741
}
17421742

1743-
function buildInfiniteQueryHooks(name: string): InfiniteQueryHooks<any> {
1743+
function buildInfiniteQueryHooks(
1744+
endpointName: string,
1745+
): InfiniteQueryHooks<any> {
17441746
const useInfiniteQuerySubscription: UseInfiniteQuerySubscription<any> = (
17451747
arg: any,
17461748
{
@@ -1754,7 +1756,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
17541756
} = {},
17551757
) => {
17561758
const { initiate } = api.endpoints[
1757-
name
1759+
endpointName
17581760
] as unknown as ApiEndpointInfiniteQuery<
17591761
InfiniteQueryDefinition<any, any, any, any, any>,
17601762
Definitions
@@ -1791,8 +1793,8 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
17911793
// with a case where the query args did change but the serialization doesn't,
17921794
// and then we never try to initiate a refetch.
17931795
defaultSerializeQueryArgs,
1794-
context.endpointDefinitions[name],
1795-
name,
1796+
context.endpointDefinitions[endpointName],
1797+
endpointName,
17961798
)
17971799
const stableSubscriptionOptions = useShallowStableValue({
17981800
refetchOnReconnect,
@@ -1930,16 +1932,16 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
19301932
{ skip = false, selectFromResult } = {},
19311933
) => {
19321934
const { select } = api.endpoints[
1933-
name
1935+
endpointName
19341936
] as unknown as ApiEndpointInfiniteQuery<
19351937
InfiniteQueryDefinition<any, any, any, any, any>,
19361938
Definitions
19371939
>
19381940
const stableArg = useStableQueryArgs(
19391941
skip ? skipToken : arg,
19401942
serializeQueryArgs,
1941-
context.endpointDefinitions[name],
1942-
name,
1943+
context.endpointDefinitions[endpointName],
1944+
endpointName,
19431945
)
19441946

19451947
type ApiRootState = Parameters<ReturnType<typeof select>>[0]

0 commit comments

Comments
 (0)