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

Method getQueryDefaults

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

* Returns the default options registered for queries whose query key partially matches the * given `queryKey`, via QueryClient#setQueryDefaults. If multiple registered defaults * match, they are merged together in registration order. * @param queryKey - The query key to look up regi

(
    queryKey: QueryKey,
  )

Source from the content-addressed store, hash-verified

973 * ```
974 */
975 getQueryDefaults(
976 queryKey: QueryKey,
977 ): OmitKeyof<QueryObserverOptions<any, any, any, any, any>, 'queryKey'> {
978 const defaults = [...this.#queryDefaults.values()]
979
980 const result: OmitKeyof<
981 QueryObserverOptions<any, any, any, any, any>,
982 'queryKey'
983 > = {}
984
985 defaults.forEach((queryDefault) => {
986 if (partialMatchKey(queryKey, queryDefault.queryKey)) {
987 Object.assign(result, queryDefault.defaultOptions)
988 }
989 })
990 return result
991 }
992
993 /**
994 * Sets default options for mutations whose mutation key partially matches the given

Callers 10

defaultQueryOptionsMethod · 0.95
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
ExamplesFunction · 0.45
buildMethod · 0.45

Calls 1

partialMatchKeyFunction · 0.90

Tested by

no test coverage detected