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

Method getQueryDefaults

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

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