Skip to content

docs(react): explain query identity and building queries inline - #322

Closed
arv wants to merge 1 commit into
mainfrom
arv/docs-1.11-query-identity
Closed

arv wants to merge 1 commit into
mainfrom
arv/docs-1.11-query-identity

Conversation

@arv

@arv arv commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Documents query interning from Zero 1.11 (rocicorp/mono#6469, #6496). This is a draft until 1.11 ships.

Changes (contents/docs/react.mdx)

New Query Identity section:

  • Build queries inline. There's no need for useMemo.
  • Building the same ZQL query again usually returns the same Query object, including with inline related() or whereExists() callbacks. So a query can be a useEffect or useMemo dependency, or a React.memo prop. The section includes an example.
  • Each call to a registered query (queries.x(args)) returns a new object. useQuery still reuses work for the same query and arguments, but use the arguments as dependencies, not the object.
  • Caveats:
    • Identity follows how the query is built.
    • Different values give different objects.
    • Identity is an optimization, not a promise, so effects that depend on a query must be safe to run again.

Why it is hedged

Interning is a cache. The code says so in zql/src/query/query-transitions.ts at rocicorp/mono 22fa3c27e ("Interning is a cache, not a guarantee"). It also stops storing past MAX_SCAN = 64 siblings in one bucket. That bucket limit was hit in a test with 100 live two-hop whereExists variants. Hashing can also make reordered where chains converge to one object, so the page says they "can be" different, not that they are.

Notes

  • assets/search-index.json is not regenerated, to avoid conflicts with the other 1.11 docs PRs. Regenerate it when merging.

Checks

prettier --check passes, and the page compiles as MDX.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RRckJnCeGsYg9nCJSxBgTJ


Generated by Claude Code

@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
zero-docs Ready Ready Preview Oct 14, 2026 3:51pm UTC

Request Review

arv commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

The Verify Signed Commit Authors check fails, but not because of what this PR changes. A cloud Claude Code session signed commit 6b169af with its own SSH key, which isn't in rocicorp/.github's allowed signers. A re-run won't fix it. To fix it, re-sign the commit with an allowed key:

git fetch origin arv/docs-1.11-query-identity
git checkout arv/docs-1.11-query-identity
git commit --amend --no-edit -S
git push --force-with-lease origin arv/docs-1.11-query-identity

Generated by Claude Code

@arv arv mentioned this pull request Oct 14, 2026
4 of 7 tasks

arv commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #325, which has all the 1.11 docs and the release notes in one PR. This commit is there unchanged.


Generated by Claude Code

@arv arv closed this Oct 14, 2026

This branch was successfully deployed

1 active deployment
Preview — 6b169af9 Deployed Oct 14, 2026 by vercel[bot]
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.

1 participant