Skip to content

Commit fbe3b44

Browse files
authored
fix: deprecate direction passed to QueryFunctionContext (#7410)
* fix: deprecate direction passed to QueryFunctionContext * chore: fix type tests
1 parent 0bb0fa3 commit fbe3b44

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

docs/framework/react/guides/query-functions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,6 @@ Additionally, [Infinite Queries](../infinite-queries) get the following options
111111
- `pageParam: TPageParam`
112112
- the page parameter used to fetch the current page
113113
- `direction: 'forward' | 'backward'`
114+
- **deprecated**
114115
- the direction of the current page fetch
116+
- To get access to the direction of the current page fetch, please add a direction to `pageParam` from `getNextPageParam` and `getPreviousPageParam`.

packages/query-core/src/__tests__/queryClient.test-d.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, expectTypeOf, it } from 'vitest'
22
import { QueryClient } from '../queryClient'
3-
import type { FetchDirection } from '../query'
43
import type { DataTag, InfiniteData, QueryKey } from '../types'
54

65
describe('getQueryData', () => {
@@ -146,7 +145,7 @@ describe('defaultOptions', () => {
146145
meta: Record<string, unknown> | undefined
147146
signal: AbortSignal
148147
pageParam?: unknown
149-
direction?: FetchDirection
148+
direction?: unknown
150149
}>()
151150
return Promise.resolve('data')
152151
},

packages/query-core/src/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,20 @@ export type QueryFunctionContext<
7171
signal: AbortSignal
7272
meta: QueryMeta | undefined
7373
pageParam?: unknown
74-
direction?: 'forward' | 'backward'
74+
/**
75+
* @deprecated
76+
* if you want access to the direction, you can add it to the pageParam
77+
*/
78+
direction?: unknown
7579
}
7680
: {
7781
queryKey: TQueryKey
7882
signal: AbortSignal
7983
pageParam: TPageParam
84+
/**
85+
* @deprecated
86+
* if you want access to the direction, you can add it to the pageParam
87+
*/
8088
direction: FetchDirection
8189
meta: QueryMeta | undefined
8290
}

0 commit comments

Comments
 (0)