Files
a59e7cccc1 fix(apollo-client): support Apollo Client v4 (#85)
## Summary

Fixes #57 — the `@dev-plugins/apollo-client` plugin throws / stops
reporting queries and mutations under Apollo Client v4.

Two internals the plugin relied on changed shape in v4:

- `getOperationName` moved from `@apollo/client/utilities` to
`@apollo/client/utilities/internal` (this is what the linked issue
comment flagged).
- The private `client.queryManager.queries` `Map` is gone in v4,
replaced by `obsQueries` (not equivalent), and `ObservableQuery.queryId`
was removed.

Rather than branching on the installed version, this switches to APIs
that are public and stable across both majors:

- Inlines the (trivial) `getOperationName` lookup instead of importing
it, so it's no longer tied to either import path.
- Replaces `client.queryManager.queries` with the public
`client.getObservableQueries()` (a `Map` in v3, a `Set` in v4 —
normalized into an array).
- Reads `document`/`variables`/`queryName` directly off each
`ObservableQuery` (public in both versions) instead of the private
`QueryInfo` map entry, and uses `getCurrentResult().data` for cached
data instead of the private `diff`/`lastDiff`.
- Falls back to a generated id when `ObservableQuery.queryId` isn't
present (v4).
- `ApolloClientType` is now a small duck-typed interface instead of
`ApolloClient<NormalizedCacheObject>`, since the `ApolloClient` class
generic was removed entirely in v4 and the old type couldn't compile
against both majors at once.
- Declares `@apollo/client` as a `peerDependencies` range (`^3.8.0 ||
^4.0.0`) — it was previously undeclared.

`client.queryManager.mutationStore` is unchanged in shape between v3 and
v4, so the mutations path didn't need changes.

## Test plan

- [x] `tsc --noEmit` passes with `@apollo/[email protected]` installed
- [x] `tsc --noEmit` passes with `@apollo/[email protected]` installed
- [x] Added `src/__tests__/utils.test.ts` covering the new
`getOperationName` lookup and the `Map`/`Set` normalization; passes
under the package's existing jest preset
- [ ] Manual check in the example app against both `@apollo/client` v3
and v4 (queries + a mutation) — happy to do this if useful before merge

---------

Co-authored-by: Vojtech Novak <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
2026-09-21 11:57:05 +02:00
..
2025-10-14 15:35:25 +08:00
2025-10-13 23:22:58 +08:00
2025-10-14 15:35:25 +08:00
2025-10-14 15:35:25 +08:00
2025-10-14 15:35:25 +08:00
2025-10-14 15:35:25 +08:00
2025-10-14 15:35:25 +08:00