-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(solid-query): Add
reconcile
option
- Loading branch information
Showing
15 changed files
with
224 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import type { | ||
QueryClientConfig as QueryCoreClientConfig, | ||
DefaultOptions as CoreDefaultOptions, | ||
QueryObserverOptions as QueryCoreObserverOptions, | ||
InfiniteQueryObserverOptions as QueryCoreInfiniteQueryObserverOptions, | ||
DefaultError, | ||
QueryKey, | ||
} from '@tanstack/query-core' | ||
import { QueryClient as QueryCoreClient } from '@tanstack/query-core' | ||
|
||
export interface QueryObserverOptions< | ||
TQueryFnData = unknown, | ||
TError = DefaultError, | ||
TData = TQueryFnData, | ||
TQueryData = TQueryFnData, | ||
TQueryKey extends QueryKey = QueryKey, | ||
TPageParam = never, | ||
> extends Omit< | ||
QueryCoreObserverOptions< | ||
TQueryFnData, | ||
TError, | ||
TData, | ||
TQueryData, | ||
TQueryKey, | ||
TPageParam | ||
>, | ||
'structuralSharing' | ||
> { | ||
/** | ||
* Set this to a reconciliation key to enable reconciliation between query results. | ||
* Set this to `false` to disable reconciliation between query results. | ||
* Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. | ||
* Defaults reconciliation key to `id`. | ||
*/ | ||
reconcile?: | ||
| string | ||
| false | ||
| ((oldData: TData | undefined, newData: TData) => TData) | ||
} | ||
|
||
export interface InfiniteQueryObserverOptions< | ||
TQueryFnData = unknown, | ||
TError = DefaultError, | ||
TData = TQueryFnData, | ||
TQueryData = TQueryFnData, | ||
TQueryKey extends QueryKey = QueryKey, | ||
TPageParam = unknown, | ||
> extends Omit< | ||
QueryCoreInfiniteQueryObserverOptions< | ||
TQueryFnData, | ||
TError, | ||
TData, | ||
TQueryData, | ||
TQueryKey, | ||
TPageParam | ||
>, | ||
'structuralSharing' | ||
> { | ||
/** | ||
* Set this to a reconciliation key to enable reconciliation between query results. | ||
* Set this to `false` to disable reconciliation between query results. | ||
* Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. | ||
* Defaults reconciliation key to `id`. | ||
*/ | ||
reconcile?: | ||
| string | ||
| false | ||
| ((oldData: TData | undefined, newData: TData) => TData) | ||
} | ||
|
||
export interface DefaultOptions<TError = DefaultError> | ||
extends CoreDefaultOptions<TError> { | ||
queries?: QueryObserverOptions<unknown, TError> | ||
} | ||
|
||
export interface QueryClientConfig extends QueryCoreClientConfig { | ||
defaultOptions?: DefaultOptions | ||
} | ||
|
||
export class QueryClient extends QueryCoreClient { | ||
constructor(config: QueryClientConfig = {}) { | ||
super(config) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.