docs(reference/QueryCache): use the v5 filters-object form in 'find' and 'findAll' examples by DucMinhNe · Pull Request #10873 · TanStack/query · GitHub
Skip to content

docs(reference/QueryCache): use the v5 filters-object form in 'find' and 'findAll' examples - #10873

Merged
sukvvon merged 1 commit into
TanStack:mainfrom
DucMinhNe:fix/docs-querycache-v5-filters
Jun 4, 2026
Merged

sukvvon merged 1 commit into
TanStack:mainfrom
DucMinhNe:fix/docs-querycache-v5-filters

Conversation

@DucMinhNe

@DucMinhNe DucMinhNe commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

The QueryCache reference examples call find / findAll with a positional query key — the v4 signature. In v5, both take a single filters object, which is what this page's own Options already document (filters?: QueryFilters). The examples are therefore out of date and won't type-check / behave as shown on v5.

Updated the three examples to the v5 form:

queryCache.find({ queryKey: ['posts'] })
queryCache.find({ queryKey })
queryCache.findAll({ queryKey })

Docs-only; brings the examples in line with the v5 API and the Options already listed on the page.

Summary by CodeRabbit

  • Documentation
    • Updated QueryCache documentation examples with corrected method signatures for find and findAll operations.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
docs/reference/QueryCache.md (2)

60-60: ⚡ Quick win

Documentation inconsistency: filters parameter is required, not optional.

The documented signature shows filters?: QueryFilters, but the actual implementation requires the filters parameter with a mandatory queryKey property: find(filters: WithRequired<QueryFilters, 'queryKey'>).

This is a pre-existing issue not introduced by this PR, but should be corrected for accuracy.

📝 Suggested documentation fix
-- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters#query-filters)
+- `filters: QueryFilters`: [Query Filters](../framework/react/guides/filters#query-filters)
+  - `queryKey` is required within the filters object
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/reference/QueryCache.md` at line 60, Update the documentation to match
the implementation: change the `filters?: QueryFilters` entry to indicate
`filters` is required and must include a `queryKey` (e.g., reflect the
implementation signature `find(filters: WithRequired<QueryFilters,
'queryKey'>)`). Ensure the docs for QueryCache (the `filters` parameter) mention
that `queryKey` is mandatory and describe its expected shape or link to the
QueryFilters type. Keep wording minimal and precise so callers know `filters` is
not optional and must contain `queryKey`.

79-80: ⚡ Quick win

Documentation format could be clearer about the single filters parameter.

The current format lists queryKey and filters as if they are separate parameters, but findAll actually accepts a single filters parameter where queryKey is an optional property of that object.

This is a pre-existing issue not introduced by this PR, but could be clarified to avoid confusion.

📝 Suggested documentation fix
 **Options**
 
-- `queryKey?: QueryKey`: [Query Keys](../framework/react/guides/query-keys.md)
-- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters)
+- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters)
+  - `queryKey?: QueryKey`: [Query Keys](../framework/react/guides/query-keys.md) - Optional query key to filter by
+  - Plus other filter options as documented in Query Filters
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/reference/QueryCache.md` around lines 79 - 80, Update the docs to
clarify that the findAll API accepts a single "filters" object parameter (type
QueryFilters) which may include an optional queryKey property, rather than two
separate parameters; change the parameter list to show a single entry like
"filters?: QueryFilters (where filters.queryKey?: QueryKey)" and update the
links to point to the QueryFilters and Query Keys docs so readers understand
queryKey is a property on the filters object (refer to the findAll function and
the QueryFilters and QueryKey types to ensure accurate wording).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/reference/QueryCache.md`:
- Line 60: Update the documentation to match the implementation: change the
`filters?: QueryFilters` entry to indicate `filters` is required and must
include a `queryKey` (e.g., reflect the implementation signature `find(filters:
WithRequired<QueryFilters, 'queryKey'>)`). Ensure the docs for QueryCache (the
`filters` parameter) mention that `queryKey` is mandatory and describe its
expected shape or link to the QueryFilters type. Keep wording minimal and
precise so callers know `filters` is not optional and must contain `queryKey`.
- Around line 79-80: Update the docs to clarify that the findAll API accepts a
single "filters" object parameter (type QueryFilters) which may include an
optional queryKey property, rather than two separate parameters; change the
parameter list to show a single entry like "filters?: QueryFilters (where
filters.queryKey?: QueryKey)" and update the links to point to the QueryFilters
and Query Keys docs so readers understand queryKey is a property on the filters
object (refer to the findAll function and the QueryFilters and QueryKey types to
ensure accurate wording).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d5c91d78-d917-4ac4-b1b7-ff3c04b0eb1d

📥 Commits

Reviewing files that changed from the base of the PR and between 8f6f923 and 98b4c28.

📒 Files selected for processing (1)
  • docs/reference/QueryCache.md

@nx-cloud

nx-cloud Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 98b4c28

Command Status Duration Result
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 6s View ↗
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 33s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-04 02:11:26 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jun 4, 2026

Copy link
Copy Markdown

@sukvvon sukvvon changed the title docs(query): use the v5 filters-object form in QueryCache examples docs(reference/QueryCache): use the v5 filters-object form in 'find' and 'findAll' examples Jun 4, 2026
@sukvvon
sukvvon merged commit 525e316 into TanStack:main Jun 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants