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

Method getQueryDefaults

packages/query-core/src/queryClient.ts:901–917  ·  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. * * @example * ```ts * const defaultOpti

(
    queryKey: QueryKey,
  )

Source from the content-addressed store, hash-verified

899 * ```
900 */
901 getQueryDefaults(
902 queryKey: QueryKey,
903 ): OmitKeyof<QueryObserverOptions<any, any, any, any, any>, 'queryKey'> {
904 const defaults = [...this.#queryDefaults.values()]
905
906 const result: OmitKeyof<
907 QueryObserverOptions<any, any, any, any, any>,
908 'queryKey'
909 > = {}
910
911 defaults.forEach((queryDefault) => {
912 if (partialMatchKey(queryKey, queryDefault.queryKey)) {
913 Object.assign(result, queryDefault.defaultOptions)
914 }
915 })
916 return result
917 }
918
919 /**
920 * 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