Expose replacement implementations of `QueryClient` APIs in UI

未关闭
#8,531 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
冷清
技术栈
typescript
领域
frontend

调研方向

首先阅读被阻塞的 issue #8530 和 ADR 0020 PR #131,以了解 guard 设计和待完成的对齐工作。检查 createUIQueryClient API,以及此处所述的 react-router v6 createHashRouter/RouterProvider 迁移。完成的标准是为乐观更新、路由加载器和 getQueryCache 变更选择并交付获批准的替代方案。

由索引模型根据 Issue 内容生成。

描述

Tracks follow-up work after the initial guard implementation (#8530) and ADR-level alignment on PR #131.


Subissues

Replacement: optimistic-update alternative for data-service-backed state (setQueryData / setQueriesData)

#8530 throws on these for data-service keys. This ticket designs and ships a sanctioned alternative so feature teams can still do optimistic UI updates. Options (pending ADR 0020 PR #131 resolution):

  • Messenger-dispatched primitive: dataService.setOptimisticCacheData(queryKey, updater) that writes to the background cache and propagates via cacheUpdated → hydrate(). Loses synchronous-write semantics; cold-path MV3 SW wake-up (100–300ms) makes worst case materially slower than the canonical pattern.
  • Sanctioned UI facade with explicit rollback on mutation failure. Preserves synchronous-write semantics.
  • Explicit ADR statement that optimistic updates for data-service keys are out of scope under Option A.

File after PR #131 alignment on which option to pursue.


Replacement: route-loader integration for data-service keys (ensureQueryData / ensureInfiniteQueryData)

#8530 throws on these for data-service keys. This ticket designs and ships a sanctioned loader-compatible alternative. Extension is mid-transition to react-router v6 data-router (createHashRouter + RouterProvider), where loader: () => queryClient.ensureQueryData(...) is the natural pattern. Options (pending PR #131 resolution):

  • ensureDataServiceQueryData(routeMessenger, queryKey) — dispatches to the service via the route messenger, awaits cache population. Composes with the UI messengers ADR RouteMessenger authorization boundary. Requires route-messenger-manager or closure-injected handle (UI messengers ADR Option 1B).
  • Block loaders from consuming data-service keys; treat route data loading as React-side only (useSuspenseQuery in route component).

File after PR #131 alignment on which option to pursue.


getQueryCache() facade**

client.getQueryCache().build/.add/.remove bypasses all instance-shadowing from #8530. Two design options:

  • Shadow getQueryCache to return a facade that gates mutating methods by key prefix
  • Stop returning a raw QueryClient from createUIQueryClient — return a narrower facade (breaking API change)

File after Layer 1 (#8530) is validated and a design option is chosen.


Dependencies

Blocked on: #8530 (Layer 1 guards)
Blocked on (replacements): ADR 0020 PR #131 resolution

主要语言
TypeScript
星标
424
派生
311
平均合并
1 天 8 小时
30 天内合并 PR
446

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MetaMask/core 的其他 Issue

查看 MetaMask/core 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。