Skip to content

Expose replacement implementations of QueryClient APIs in UI #8531

@MajorLift

Description

@MajorLift

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 cacheUpdatedhydrate(). 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions