Skip to content

Commit

Permalink
fix: deprecate direction passed to QueryFunctionContext (#7410)
Browse files Browse the repository at this point in the history
* fix: deprecate direction passed to QueryFunctionContext

* chore: fix type tests
  • Loading branch information
TkDodo committed May 10, 2024
1 parent 0bb0fa3 commit fbe3b44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/framework/react/guides/query-functions.md
Expand Up @@ -111,4 +111,6 @@ Additionally, [Infinite Queries](../infinite-queries) get the following options
- `pageParam: TPageParam`
- the page parameter used to fetch the current page
- `direction: 'forward' | 'backward'`
- **deprecated**
- the direction of the current page fetch
- To get access to the direction of the current page fetch, please add a direction to `pageParam` from `getNextPageParam` and `getPreviousPageParam`.
3 changes: 1 addition & 2 deletions packages/query-core/src/__tests__/queryClient.test-d.tsx
@@ -1,6 +1,5 @@
import { describe, expectTypeOf, it } from 'vitest'
import { QueryClient } from '../queryClient'
import type { FetchDirection } from '../query'
import type { DataTag, InfiniteData, QueryKey } from '../types'

describe('getQueryData', () => {
Expand Down Expand Up @@ -146,7 +145,7 @@ describe('defaultOptions', () => {
meta: Record<string, unknown> | undefined
signal: AbortSignal
pageParam?: unknown
direction?: FetchDirection
direction?: unknown
}>()
return Promise.resolve('data')
},
Expand Down
10 changes: 9 additions & 1 deletion packages/query-core/src/types.ts
Expand Up @@ -71,12 +71,20 @@ export type QueryFunctionContext<
signal: AbortSignal
meta: QueryMeta | undefined
pageParam?: unknown
direction?: 'forward' | 'backward'
/**
* @deprecated
* if you want access to the direction, you can add it to the pageParam
*/
direction?: unknown
}
: {
queryKey: TQueryKey
signal: AbortSignal
pageParam: TPageParam
/**
* @deprecated
* if you want access to the direction, you can add it to the pageParam
*/
direction: FetchDirection
meta: QueryMeta | undefined
}
Expand Down

0 comments on commit fbe3b44

Please sign in to comment.