Skip to content

Commit

Permalink
feat: add options to setQueryData
Browse files Browse the repository at this point in the history
  • Loading branch information
boschni committed Oct 7, 2020
1 parent de0492f commit 1f5b13e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ interface FetchMoreOptions {
direction: 'forward' | 'backward'
}

interface SetDataOptions {
export interface SetDataOptions {
pageParams?: unknown[]
updatedAt?: number
}
Expand Down
7 changes: 4 additions & 3 deletions src/core/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
QueryOptions,
RefetchOptions,
} from './types'
import type { QueryState } from './query'
import type { QueryState, SetDataOptions } from './query'
import type { QueryCache } from './queryCache'
import { QueriesObserver } from './queriesObserver'
import { QueryObserver } from './queryObserver'
Expand Down Expand Up @@ -109,11 +109,12 @@ export class QueryClient {

setQueryData<TData>(
queryKey: QueryKey,
updater: Updater<TData | undefined, TData>
updater: Updater<TData | undefined, TData>,
options?: SetDataOptions
): TData {
const parsedOptions = parseQueryArgs(queryKey)
const defaultedOptions = this.defaultQueryOptions(parsedOptions)
return this.cache.build(defaultedOptions).setData(updater)
return this.cache.build(defaultedOptions).setData(updater, options)
}

getQueryState<TData = unknown, TError = undefined>(
Expand Down

0 comments on commit 1f5b13e

Please sign in to comment.