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

Method setQueryDefaults

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

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