Skip to content

feat(client,tanstack-react-query): one description of queries for both loaders - #8163

Closed
KATT wants to merge 6 commits into
claude/sweet-albattani-gdth4hfrom
claude/shared-query-descriptions
Closed

KATT wants to merge 6 commits into
claude/sweet-albattani-gdth4hfrom
claude/shared-query-descriptions

Conversation

@KATT

@KATT KATT commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Why

What

  • experimental_query, experimental_infiniteQuery, experimental_dataOf and experimental_perItem move to @trpc/client. The TanStack package re-exports them.
  • experimental_load(client, entries) replaces experimental_nested(). It returns a promise per key.
  • loadHandles() takes the same entries as prefetch entries. { wait: [...] } makes them ensure entries.
  • experimental_perItem (was experimental_entryPerItem) takes an object of entries per item, which read each other, and nests. null skips an entry in both loaders.
  • The dataOf(entry, cb) form stays: entry types don't record what they read, so without it TanStack can't type unfinished handles.
  • Inputs and data are plain objects, arrays and primitives: no special Map, Set or Date handling.
function postQueries(trpc: experimental_QueryProcedures<AppRouter>, slug: string) {
  const post = experimental_query(trpc.post.bySlug, { slug });
  return { post, author: experimental_query(trpc.author.byId, { id: experimental_dataOf(post).authorId }) };
}
const res = experimental_load(client, postQueries(client, slug));
const [handles, { post }] = await loadHandles(trpc, postQueries(trpc, slug), { wait: ['post'] });

Links

Alternatives considered

  • Dropping the dataOf callback: unsound handle types.
  • A list in a per-item query, at the top level, as nested lists: its type can't know, so it's one flat list.

Testing

  • Regression check: load.test.ts (ported from nested.test.ts) and handles.shared.test.tsx; the old suites pass unchanged except for error messages.

AI model

Claude Opus 5.5

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

KATT and others added 2 commits November 23, 2026 23:43
…ith either loader

`experimental_query()`, `experimental_infiniteQuery()`, `experimental_dataOf()`
and `experimental_perItem()` now live in `@trpc/client` and build plain
descriptions. `experimental_load(client, entries)` loads one as promises by
key, replacing `experimental_nested()` and its `.with()` / `.map()` builder.
`loadHandles()` loads the same description: its entries become prefetch
entries, and `{ wait: [...] }` makes them ensure entries.

The TanStack Query handles take the shared `dataOf` refs and per-item state
from the client, so one description reads alike in both packages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The vanilla page loads a description with `experimental_load()`, per item
with `experimental_perItem()`, and shows infinite queries and the same
description in `loadHandles()`. The TanStack Query page gains `{ wait }`.
The kitchen-sink nested demo uses the new API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
examples-next-minimal-starter Ready Ready Preview Nov 24, 2026 12:59am UTC
examples-todomvc Ready Ready Preview Nov 24, 2026 12:59am UTC
next-prisma-starter Ready Ready Preview Nov 24, 2026 12:59am UTC
next-prisma-websockets-starter Ready Ready Preview Nov 24, 2026 12:59am UTC
tanstack-start-sse-chat Ready Ready Preview Nov 24, 2026 12:59am UTC
trpc-next-app-dir Ready Ready Preview Nov 24, 2026 12:59am UTC
www Ready Ready Preview Nov 24, 2026 12:59am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@vercel
vercel Bot temporarily deployed to Preview – trpc-next-app-dir November 23, 2026 22:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-todomvc November 23, 2026 22:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – next-prisma-starter November 23, 2026 22:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – examples-next-minimal-starter November 23, 2026 22:48 Inactive
…ting, and `null` to skip

`experimental_perItem()`'s callback can return an object of entries, which
read each other and run once per item, and entries per item nest: a list
per item, of a list in the item or in an item's query. A list in a query
that runs for every item is one flat list, in that order. `null` skips an
entry, in both loaders. `loadHandles()` loads an object per item as a group
of entries per item.

Inputs and data are plain objects, arrays and primitives: the special
handling of Maps, Sets, Dates and class instances goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…path` hook

`experimental_query()` reads the path that a tRPC client's and an options
proxy's `toString()` name already, so the client proxy is as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
KATT added a commit that referenced this pull request Nov 24, 2026
…elining PR

Bring the client, server and tests from the tail of the stack (#8163,
#8176) into this PR: `experimental_query()` / `experimental_dataOf()` /
`experimental_perItem()` and `experimental_load()` in `@trpc/client`
replace `experimental_nested()`, each query is an operation of its own
so `retryLink` retries only what failed, and
`experimental_isPipelineFallback()` tells a fallback apart. Adds the
kitchen-sink retries page.

The TanStack-only parts stay in #8041: the docs here don't link to the
TanStack nested-queries page, `unstable-internals` doesn't re-export what
only the handles use, and `RequestPath` comes with them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
KATT added a commit that referenced this pull request Nov 24, 2026
Folds #8163 and #8176 into this PR: the handles load the shared
descriptions of `@trpc/client`, and the tree now matches the tail of the
stack (f4133ea), with the TanStack docs, demos and blog kitchen sink.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@KATT

KATT commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Folded into the bottom of the stack, so closing:

The branch stays.

@KATT KATT closed this Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 25, 2026

This branch was successfully deployed

5 active deployments
Preview – www — 4ce8a062 Deployed Nov 24, 2026 by vercel[bot]
Preview – trpc-next-app-dir — 4ce8a062 Deployed Nov 24, 2026 by vercel[bot]
Preview – next-prisma-starter — 4ce8a062 Deployed Nov 24, 2026 by vercel[bot]
Preview – examples-next-minimal-starter — 4ce8a062 Deployed Nov 24, 2026 by vercel[bot]
Preview – examples-todomvc — 4ce8a062 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant