-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(query-core, react-query, vue-query): backport v5 some apis to v4 #9140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v16.19.0 | ||
22.12.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,14 +141,16 @@ export class MutationObserver< | |
? this.currentMutation.state | ||
: getDefaultState<TData, TError, TVariables, TContext>() | ||
|
||
const isLoading = state.status === 'loading' | ||
const result: MutationObserverBaseResult< | ||
TData, | ||
TError, | ||
TVariables, | ||
TContext | ||
> = { | ||
...state, | ||
isLoading: state.status === 'loading', | ||
isLoading, | ||
isPending: isLoading, | ||
Comment on lines
+152
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use isPending like v5 |
||
isSuccess: state.status === 'success', | ||
isError: state.status === 'error', | ||
isIdle: state.status === 'idle', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { notifyManager } from './notifyManager' | |
import { Subscribable } from './subscribable' | ||
import type { QueryFilters } from './utils' | ||
import type { Action, QueryState } from './query' | ||
import type { NotifyEvent, QueryKey, QueryOptions } from './types' | ||
import type { NotifyEvent, OmitKeyof, QueryKey, QueryOptions } from './types' | ||
import type { QueryClient } from './queryClient' | ||
import type { QueryObserver } from './queryObserver' | ||
|
||
|
@@ -166,8 +166,21 @@ export class QueryCache extends Subscribable<QueryCacheListener> { | |
} | ||
|
||
find<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData>( | ||
arg1: QueryKey, | ||
arg2?: QueryFilters, | ||
filters: QueryFilters, | ||
): Query<TQueryFnData, TError, TData> | undefined | ||
Comment on lines
168
to
+170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a function overload accepting only a |
||
/** | ||
* @deprecated This method should be used with only one object argument. | ||
*/ | ||
find<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData>( | ||
queryKey: QueryKey, | ||
filters?: OmitKeyof<QueryFilters, 'queryKey'>, | ||
): Query<TQueryFnData, TError, TData> | undefined | ||
/** | ||
* @deprecated This method should be used with only one object argument. | ||
*/ | ||
find<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData>( | ||
arg1: QueryKey | QueryFilters, | ||
arg2?: OmitKeyof<QueryFilters, 'queryKey'>, | ||
Comment on lines
+171
to
+183
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tagged jsdoc |
||
): Query<TQueryFnData, TError, TData> | undefined { | ||
const [filters] = parseFilterArgs(arg1, arg2) | ||
|
||
|
@@ -178,10 +191,28 @@ export class QueryCache extends Subscribable<QueryCacheListener> { | |
return this.queries.find((query) => matchQuery(filters, query)) | ||
} | ||
|
||
findAll(queryKey?: QueryKey, filters?: QueryFilters): Query[] | ||
findAll(filters?: QueryFilters): Query[] | ||
findAll(arg1?: QueryKey | QueryFilters, arg2?: QueryFilters): Query[] | ||
findAll(arg1?: QueryKey | QueryFilters, arg2?: QueryFilters): Query[] { | ||
/** | ||
* @deprecated This method should be used with only one object argument. | ||
*/ | ||
findAll( | ||
queryKey?: QueryKey, | ||
filters?: OmitKeyof<QueryFilters, 'queryKey'>, | ||
): Query[] | ||
/** | ||
* @deprecated This method should be used with only one object argument. | ||
*/ | ||
findAll( | ||
arg1?: QueryKey | QueryFilters, | ||
arg2?: OmitKeyof<QueryFilters, 'queryKey'>, | ||
): Query[] | ||
/** | ||
* @deprecated This method should be used with only one object argument. | ||
*/ | ||
findAll( | ||
arg1?: QueryKey | QueryFilters, | ||
arg2?: OmitKeyof<QueryFilters, 'queryKey'>, | ||
): Query[] { | ||
Comment on lines
+195
to
+215
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tagged jsdoc |
||
const [filters] = parseFilterArgs(arg1, arg2) | ||
return Object.keys(filters).length > 0 | ||
? this.queries.filter((query) => matchQuery(filters, query)) | ||
|
Uh oh!
There was an error while loading. Please reload this page.