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

Method getQueryDefaults

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

969 * ```
970 */
971 getQueryDefaults(
972 queryKey: QueryKey,
973 ): OmitKeyof<QueryObserverOptions<any, any, any, any, any>, 'queryKey'> {
974 const defaults = [...this.#queryDefaults.values()]
975
976 const result: OmitKeyof<
977 QueryObserverOptions<any, any, any, any, any>,
978 'queryKey'
979 > = {}
980
981 defaults.forEach((queryDefault) => {
982 if (partialMatchKey(queryKey, queryDefault.queryKey)) {
983 Object.assign(result, queryDefault.defaultOptions)
984 }
985 })
986 return result
987 }
988
989 /**
990 * 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