fix: devtools compatibility with @apollo/client 3.13.9#659
fix: devtools compatibility with @apollo/client 3.13.9#659
Conversation
- Add fetchQueryObservable shim for Apollo Client 3.8+ where it was replaced by fetchConcastWithInfo (used by apollo-inspector) - Add null-safety for mutationStore in tracker and recent-activity publishers - Widen @apollo/client dev dependency to >=3.6.0 Agent-Logs-Url: https://github.com/microsoft/graphitation/sessions/c31ae7e8-02d9-44de-a2af-1739a775a8fc Co-authored-by: pavelglac <42679661+pavelglac@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/graphitation/sessions/c31ae7e8-02d9-44de-a2af-1739a775a8fc Co-authored-by: pavelglac <42679661+pavelglac@users.noreply.github.com>
|
@copilot I still do not see queries in devtools |
… getQuery alias, apply shim early Three critical fixes for Apollo Client 3.8+/3.13.9 compatibility: 1. Wrap fetchConcastWithInfo to route through fetchQueryObservable when apollo-inspector's hook is installed. Previously the shim only added fetchQueryObservable but Apollo Client never called it - now internal calls to fetchConcastWithInfo trigger the hook. 2. Add getQuery as an alias for getOrCreateQuery (renamed in 3.8+). apollo-inspector calls queryManager.getQuery() in its verbose hook. 3. Apply compat shim in rempl-wrapper.runAllHooks() so ALL publishers benefit (tracker, recent-activity, operations-tracker) instead of only when operations tracking starts. Also reverts @apollo/client devDep from >=3.6.0 back to ~3.6.0 since the wider range accidentally pulled in v4.x at build time. Agent-Logs-Url: https://github.com/microsoft/graphitation/sessions/f7c76f3f-a3f4-4e3d-a426-bfd6a4ce2472 Co-authored-by: pavelglac <42679661+pavelglac@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/graphitation/sessions/f7c76f3f-a3f4-4e3d-a426-bfd6a4ce2472 Co-authored-by: pavelglac <42679661+pavelglac@users.noreply.github.com>
In commit 55934f2, I've made significant improvements to the compatibility shim: For operations recording: The original shim only added For the tracker: The compat shim is now applied early in However, the tracker tab reads |
Operations are missing from devtools recordings and the tracker tab with
@apollo/client3.13.9 because of three internal API changes in Apollo Client 3.8+:queryManager.fetchQueryObservablewas removed and replaced by the privatefetchConcastWithInfoqueryManager.getQuerywas renamed togetOrCreateQueryqueryManager.mutationStorecan beundefined(only initialized whenonBroadcastis provided)Compatibility shim (
apollo-client-compat.ts)New helper that patches the queryManager to bridge the internal API changes for
apollo-inspector:fetchConcastWithInfo→fetchQueryObservablebridge: Creates afetchQueryObservableshim backed by the originalfetchConcastWithInfo, then wrapsfetchConcastWithInfoso that Apollo Client's own internal calls are routed throughfetchQueryObservablewhenapollo-inspectorhas hooked it. This ensures operation tracking hooks are triggered.getQuery→getOrCreateQueryalias:apollo-inspectorcallsqueryManager.getQuery(queryId)inside its verbose tracking hook, which was renamed in 3.8+.mutationStoreinitialization: EnsuresmutationStoreis always a real object so mutations are tracked and devtools code can iterate it.Early shim application via
rempl-wrapperThe compat shim is now applied in
rempl-wrapper.runAllHooks()when clients are first discovered, so all publishers (tracker, recent-activity, operations-tracker) benefit from the compatibility patches before they begin polling.Null-safety for
mutationStoregetMutations()in bothapollo-tracker-publisherandapollo-recent-activity-publishernow falls back to{}whenmutationStoreis undefined