MCPcopy Create free account
hub / github.com/TanStack/query / setQueryDefaults

Method setQueryDefaults

packages/query-core/src/queryClient.ts:871–889  ·  view source on GitHub ↗

* Sets default options for queries whose query key partially matches the given `queryKey`. * * If several registered query defaults match a given query key, they are merged together in * registration order by QueryClient#getQueryDefaults, so register defaults from the * most gene

(
    queryKey: QueryKey,
    options: Partial<
      OmitKeyof<
        QueryObserverOptions<TQueryFnData, TError, TData, TQueryData>,
        'queryKey'
      >
    >,
  )

Source from the content-addressed store, hash-verified

869 * ```
870 */
871 setQueryDefaults<
872 TQueryFnData = unknown,
873 TError = DefaultError,
874 TData = TQueryFnData,
875 TQueryData = TQueryFnData,
876 >(
877 queryKey: QueryKey,
878 options: Partial<
879 OmitKeyof<
880 QueryObserverOptions<TQueryFnData, TError, TData, TQueryData>,
881 'queryKey'
882 >
883 >,
884 ): void {
885 this.#queryDefaults.set(hashKey(queryKey), {
886 queryKey,
887 defaultOptions: options,
888 })
889 }
890
891 /**
892 * Returns the default options registered for queries whose query key partially matches the

Callers 15

Example6Function · 0.95
Example7Function · 0.95
Example8Function · 0.95
Example9Function · 0.95
Example10Function · 0.95
Example6Function · 0.95
Example7Function · 0.95
Example8Function · 0.95
Example9Function · 0.95
Example10Function · 0.95
Example6Function · 0.45
Example7Function · 0.45

Calls 1

hashKeyFunction · 0.90

Tested by

no test coverage detected