Align ForestRun watchFragment with Apollo Client 3.13.9#655
Align ForestRun watchFragment with Apollo Client 3.13.9#655
Conversation
📊 Benchmark Analysis Report✅ No significant performance changes detected Threshold: 5% change Updated: 2026-03-30T14:35:10.608Z |
| ...otherOptions | ||
| } = options; | ||
| const query = this["getFragmentDoc"](fragment, fragmentName); | ||
| const id = typeof from === "string" ? from : this.identify(from); |
There was a problem hiding this comment.
@copilot Fix is based on this: apollographql/apollo-client#12052
There was a problem hiding this comment.
Applied the same fix from that PR in commit 8e437c6. Changed the id assignment to handle from === undefined by passing it through directly instead of calling this.identify(undefined), which avoids the unwanted warning.
Agent-Logs-Url: https://github.com/microsoft/graphitation/sessions/1188cddb-5227-4dbe-8a69-1283c9aeebd2 Co-authored-by: pavelglac <42679661+pavelglac@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot verify the implementation of watchFragment with the https://github.com/apollographql/apollo-client/blob/main/src/cache/core/cache.ts. Make ForestRun fully compatible with apollo version 3.13.9. |
Agent-Logs-Url: https://github.com/microsoft/graphitation/sessions/67058345-f43e-42f4-9747-050ad6c70880 Co-authored-by: pavelglac <42679661+pavelglac@users.noreply.github.com>
Verified the implementation against Apollo Client 3.13.9's
All 23 own tests and 114 Apollo compat tests pass. |
|
@copilot Check the ForestRun integrity. Why I need watchFragmentInternal? I do not see how this can be performant. Also you are missing tests. |
Agent-Logs-Url: https://github.com/microsoft/graphitation/sessions/6e241c01-f93d-4cff-a0fd-b99cd56d337a Co-authored-by: pavelglac <42679661+pavelglac@users.noreply.github.com>
Fixed in dbeb099. Two issues found and addressed:
Re: why |
|
@copilot then i would expect this optimalization is part of the watchFragment. Refactor it to use observable and also ForestRun optimalization. |
…hFragment Agent-Logs-Url: https://github.com/microsoft/graphitation/sessions/f84e3233-0a71-432d-962b-8a7f4d44a82c Co-authored-by: pavelglac <42679661+pavelglac@users.noreply.github.com>
Refactored in fa6a230.
The All 24 own test suites (1085 tests) and 114 Apollo compat test suites (1661 tests) pass. |
Aligns ForestRun's
watchFragmentimplementation with Apollo Client 3.13.9'sApolloCache.watchFragmentAPI.Changes Made
Observable(from@apollo/client/utilities) instead of a custom{ subscribe: ... }pattern, matching Apollo 3.13.9's APIfromparameter: AcceptsStoreObject | Reference | string(addedReferencesupport)variablesoption: Added genericTVarssupport for thevariablesoption<TData, TVars>matching Apollo's signaturediffOptions: UsesCache.DiffOptions<TData, TVars>for proper typingdataState: Removed non-standarddataStatefield from result to match Apollo'sWatchFragmentResultfrom === undefinedfix: Handles undefinedfromgracefully to avoid callingthis.identify(undefined), based on apollo-client PR #12052watchFragment: ThefragmentWatchesoptimization (registering watches keyed by entity ID for efficient lookups viacollectAffectedWatches/transaction.affectedNodes) is now directly insidewatchFragment's Observable subscriber. WhenoptimizeFragmentReadsis enabled and an entity ID is available,watchFragmentcomputes the initial diff, delivers it viaobserver.next(), and registers directly infragmentWatches. Otherwise, it falls back towatchOperation. The separatewatchFragmentInternalmethod has been removed, eliminating unnecessary indirection.watch()method simplified: For direct callers (e.g., QueryManager), the fragment watch registration is inlined inwatch()— just accumulate/delete infragmentWatcheswithoutimmediatehandling, since direct callers don't useimmediate.watchFragmenttests: 12 new tests covering allfromtypes (string, StoreObject, Reference), change notifications, deduplication, unsubscribe cleanup, missing data,from === undefined, bothoptimizeFragmentReadson/off paths, and result shape validation.⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.