Skip to content

fix: devtools compatibility with @apollo/client 3.13.9#659

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/verify-devtools-compatibility
Draft

fix: devtools compatibility with @apollo/client 3.13.9#659
Copilot wants to merge 4 commits intomainfrom
copilot/verify-devtools-compatibility

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Operations are missing from devtools recordings and the tracker tab with @apollo/client 3.13.9 because of three internal API changes in Apollo Client 3.8+:

  1. queryManager.fetchQueryObservable was removed and replaced by the private fetchConcastWithInfo
  2. queryManager.getQuery was renamed to getOrCreateQuery
  3. queryManager.mutationStore can be undefined (only initialized when onBroadcast is provided)

Compatibility shim (apollo-client-compat.ts)

New helper that patches the queryManager to bridge the internal API changes for apollo-inspector:

  • fetchConcastWithInfofetchQueryObservable bridge: Creates a fetchQueryObservable shim backed by the original fetchConcastWithInfo, then wraps fetchConcastWithInfo so that Apollo Client's own internal calls are routed through fetchQueryObservable when apollo-inspector has hooked it. This ensures operation tracking hooks are triggered.
  • getQuerygetOrCreateQuery alias: apollo-inspector calls queryManager.getQuery(queryId) inside its verbose tracking hook, which was renamed in 3.8+.
  • mutationStore initialization: Ensures mutationStore is always a real object so mutations are tracked and devtools code can iterate it.
  • Idempotency guard: Prevents the shim from being applied multiple times to the same client.

Early shim application via rempl-wrapper

The 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 mutationStore

  • getMutations() in both apollo-tracker-publisher and apollo-recent-activity-publisher now falls back to {} when mutationStore is undefined

Copilot AI and others added 2 commits March 30, 2026 15:47
- 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>
@pavelglac
Copy link
Copy Markdown
Contributor

@copilot I still do not see queries in devtools

Copilot AI and others added 2 commits March 31, 2026 13:15
… 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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot I still do not see queries in devtools

In commit 55934f2, I've made significant improvements to the compatibility shim:

For operations recording: The original shim only added fetchQueryObservable to the queryManager, but Apollo Client 3.13.9 never actually calls it — it calls fetchConcastWithInfo instead. Now the shim wraps fetchConcastWithInfo so internal calls are routed through fetchQueryObservable, which triggers apollo-inspector's hooks. I also added a getQuerygetOrCreateQuery alias since apollo-inspector calls getQuery() in its hook (renamed in 3.8+).

For the tracker: The compat shim is now applied early in rempl-wrapper.runAllHooks() when clients are first discovered, so ALL publishers (tracker, recent-activity, operations) benefit. This ensures mutationStore exists before any data is polled.

However, the tracker tab reads queryManager.queries (a Map of QueryInfo objects) directly, and from my analysis of the compiled 3.13.9 source, this Map and its QueryInfo properties (document, variables, graphQLErrors, networkError, lastDiff, lastWrite) all still exist and are accessible. Could you share more details about what you see in the tracker tab — is it completely empty, or are some queries missing? Any console errors would be very helpful for further investigation.

Copilot AI requested a review from pavelglac March 31, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants