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

Method setQueryDefaults

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

862 * ```
863 */
864 setQueryDefaults<
865 TQueryFnData = unknown,
866 TError = DefaultError,
867 TData = TQueryFnData,
868 TQueryData = TQueryFnData,
869 >(
870 queryKey: QueryKey,
871 options: Partial<
872 OmitKeyof<
873 QueryObserverOptions<TQueryFnData, TError, TData, TQueryData>,
874 'queryKey'
875 >
876 >,
877 ): void {
878 this.#queryDefaults.set(hashKey(queryKey), {
879 queryKey,
880 defaultOptions: options,
881 })
882 }
883
884 /**
885 * 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