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

Method setQueryDefaults

packages/query-core/src/queryClient.ts:943–961  ·  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

941 * ```
942 */
943 setQueryDefaults<
944 TQueryFnData = unknown,
945 TError = DefaultError,
946 TData = TQueryFnData,
947 TQueryData = TQueryFnData,
948 >(
949 queryKey: QueryKey,
950 options: Partial<
951 OmitKeyof<
952 QueryObserverOptions<TQueryFnData, TError, TData, TQueryData>,
953 'queryKey'
954 >
955 >,
956 ): void {
957 this.#queryDefaults.set(hashKey(queryKey), {
958 queryKey,
959 defaultOptions: options,
960 })
961 }
962
963 /**
964 * 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