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

Method getQueryDefaults

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

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