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

Method setQueryDefaults

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

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