query icon indicating copy to clipboard operation
query copied to clipboard

No information about matchQuery in the docs

Open swingthrough opened this issue 1 year ago • 2 comments

Describe the bug

I saw this tweet: https://x.com/TkDodo/status/1744604450566680864

queryClient.invalidateQueries({ predicate: query => matchQuery(['comments']) || matchQuery(['likes']) })

matchQuery can be imported from RQ

So I tried searching matchQuery in the docs but nothing was found. Shouldn't this be mentioned somewhere?

Edit: I also found usage of matchQuery in this article: https://tkdodo.eu/blog/automatic-query-invalidation-after-mutations#use-the-meta-option

but the usage is a little bit different:

matchQuery({ queryKey }, query)

Your minimal, reproducible example

...

Steps to reproduce

  1. Go to the docs
  2. Search for matchQuery
  3. No results are found

Expected behavior

I'd expect matchQuery to be documented.

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

docs

Tanstack Query adapter

None

TanStack Query version

latest

TypeScript version

No response

Additional context

No response

swingthrough avatar Jun 24 '24 11:06 swingthrough

but the usage is a little bit different:

the syntax in the tweet is wrong.

I'd expect matchQuery to be documented.

please make a PR and add it to this page: https://tanstack.com/query/latest/docs/framework/react/guides/filters

TkDodo avatar Jun 24 '24 12:06 TkDodo

please make a PR and add it to this page: https://tanstack.com/query/latest/docs/framework/react/guides/filters

That page lists properties of QueryFilters interface, it doesn't have an example of such utilities as matchQuery, matchMutation and others that are defined here: https://github.com/TanStack/query/blob/63552449845792954a4ea6801d843da3fbb4e293/packages/query-core/src/utils.ts#L103

Is it really the right place for it? Anyway, I'm not sure what the phrasing should be, that's why I was looking for it in the first place.

swingthrough avatar Jun 25 '24 12:06 swingthrough