File: packages/react-data-query/src/createUIQueryClient.ts
Size: M | Hours: 6–10
Problem
Under ADR 0020 Option A, the messenger-routed proxy queryFn (createUIQueryClient.ts:64-82) and OmitKeyof wrapper hooks enforce that the background owns data-service-keyed cache entries. Neither mechanism covers the QueryClient instance surface. UI code with a handle on queryClient (via ui/contexts/query-client.ts or useQueryClient()) can call instance methods that bypass the proxy or cross the ownership boundary without warning.
Currently dormant (DATA_SERVICES = []). Becomes live on first data-service registration.
Solution
Mirror the existing invalidateQueries shadow at createUIQueryClient.ts:145-168. For each method below, shadow on the returned client and throw a descriptive error if the query key matches a registered data-service prefix. Non-data-service keys pass through unchanged.
Methods to guard:
setQueryDefaults — per-key cache-policy override; ADR 0020:307-316 moves cache policy to the service layer
setMutationDefaults — no data-service mutations today; block preemptively
setDefaultOptions — block only when options.queries.queryFn is set
prefetchQuery / prefetchInfiniteQuery — pending policy decision on whether UI-side prefetch is in scope; block until decided
fetchQuery / fetchInfiniteQuery — same
setQueryData / setQueriesData — block; replacement implementation tracked separately (see Dependencies)
ensureQueryData / ensureInfiniteQueryData — block; replacement implementation tracked separately (see Dependencies)
Acceptance Criteria
Dependencies
Depends on: MetaMask/metamask-extension#41183 (merged)
Dependents: MetaMask/metamask-extension#41977
Follow-up epic (Layer 2 + replacements): #8531
File:
packages/react-data-query/src/createUIQueryClient.tsSize: M | Hours: 6–10
Problem
Under ADR 0020 Option A, the messenger-routed proxy
queryFn(createUIQueryClient.ts:64-82) andOmitKeyofwrapper hooks enforce that the background owns data-service-keyed cache entries. Neither mechanism covers theQueryClientinstance surface. UI code with a handle onqueryClient(viaui/contexts/query-client.tsoruseQueryClient()) can call instance methods that bypass the proxy or cross the ownership boundary without warning.Currently dormant (
DATA_SERVICES = []). Becomes live on first data-service registration.Solution
Mirror the existing
invalidateQueriesshadow atcreateUIQueryClient.ts:145-168. For each method below, shadow on the returned client and throw a descriptive error if the query key matches a registered data-service prefix. Non-data-service keys pass through unchanged.Methods to guard:
setQueryDefaults— per-key cache-policy override; ADR 0020:307-316 moves cache policy to the service layersetMutationDefaults— no data-service mutations today; block preemptivelysetDefaultOptions— block only whenoptions.queries.queryFnis setprefetchQuery/prefetchInfiniteQuery— pending policy decision on whether UI-side prefetch is in scope; block until decidedfetchQuery/fetchInfiniteQuery— samesetQueryData/setQueriesData— block; replacement implementation tracked separately (see Dependencies)ensureQueryData/ensureInfiniteQueryData— block; replacement implementation tracked separately (see Dependencies)Acceptance Criteria
setDefaultOptionsonly throws whenoptions.queries.queryFnis set; other client-wide tuning unaffectedinvalidateQueriesshadow, wrapper hooks, andhydrate-based cache-sync continue to workuseHistoricalPrices,activity-v2/hooks,useMerklRewards) still passDependencies
Depends on: MetaMask/metamask-extension#41183 (merged)
Dependents: MetaMask/metamask-extension#41977
Follow-up epic (Layer 2 + replacements): #8531