Query Hook Migration
Objective
Move all read-side data fetching behind query hooks that use the shared key factory.Rules
- all reads belong in
hooks/queries/ - no page or component should call raw
fetchfor app data reads - every
useQuerymust useglobalKeysoruserKeys(userId) - user-scoped queries must be disabled when
userIdor other required auth context is missing
Migration Pattern
Before:Required Review Work
For each query hook:- confirm whether the data is user-scoped or global
- replace inline keys with factory keys
- confirm
enabledguards still prevent unauthenticated fetches - update any in-file invalidation to use the same factory
- remove local key builder helpers
Domains To Migrate
Suggested grouping:- core: accounts, manual accounts, holdings, net worth, daily snapshots
- transactions: unified, investment, manual, account-specific variants
- assets/liabilities: properties, vehicles, physical assets, liabilities, other assets
- crypto: wallets, crypto holdings, plaid crypto holdings, coinbase data
- vault/chat/settings: vault folders/documents, chat sessions, user info, personal info, settings
- remaining app domains: subscriptions, earnings, sync status, alerts, research, news, market data
Fetch Extraction Rule
If a page/component currently does this:hooks/queries/.
Example naming:
hooks/queries/use-sync-status.tshooks/queries/use-research-sessions.tshooks/queries/use-account-refresh-status.ts
Acceptance Criteria
- no raw read-side
fetchcalls remain in pages/components for app data - every query hook uses the shared factory
- every user-scoped query is isolated by
userId