MCPcopy Index your code
hub / github.com/TanStack/query / matchQuery

Function matchQuery

packages/query-core/src/utils.ts:127–173  ·  view source on GitHub ↗
(
  filters: QueryFilters,
  query: Query<any, any, any, any>,
)

Source from the content-addressed store, hash-verified

125}
126
127export function matchQuery(
128 filters: QueryFilters,
129 query: Query<any, any, any, any>,
130): boolean {
131 const {
132 type = 'all',
133 exact,
134 fetchStatus,
135 predicate,
136 queryKey,
137 stale,
138 } = filters
139
140 if (queryKey) {
141 if (exact) {
142 if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
143 return false
144 }
145 } else if (!partialMatchKey(query.queryKey, queryKey)) {
146 return false
147 }
148 }
149
150 if (type !== 'all') {
151 const isActive = query.isActive()
152 if (type === 'active' && !isActive) {
153 return false
154 }
155 if (type === 'inactive' && isActive) {
156 return false
157 }
158 }
159
160 if (typeof stale === 'boolean' && query.isStale() !== stale) {
161 return false
162 }
163
164 if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
165 return false
166 }
167
168 if (predicate && !predicate(query)) {
169 return false
170 }
171
172 return true
173}
174
175export function matchMutation(
176 filters: MutationFilters,

Callers 3

persisterFnFunction · 0.90
findMethod · 0.90
findAllMethod · 0.90

Calls 5

hashQueryKeyByOptionsFunction · 0.85
partialMatchKeyFunction · 0.85
isActiveMethod · 0.80
isStaleMethod · 0.80
predicateFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…