@apollo/client@4.0.0-alpha.19
Breaking Changes📦 apollo-client
⚠ 1 breaking✨ 3 features🔧 5 symbols
Summary
Adds subscription restart capability and full‑lifecycle deduplication, while changing early‑unsubscribe behavior for ObservableQuery.
⚠️ Breaking Changes
- Unsubscribing from an `ObservableQuery` before any value is emitted now removes the query from the internal tracked list, meaning it will no longer participate in query deduplication. Code that relied on the query remaining deduplicated after early unsubscribe must be updated to handle the removal or avoid early unsubscribe.
Migration Steps
- If your application unsubscribes from an `ObservableQuery` before any data is received and expects it to stay in the deduplication pool, adjust the logic to either keep the subscription alive or handle the fact that it will be removed.
- To retain the previous behavior of forcing a new connection for a subscription, set `queryDeduplication: false` in the operation's `context`.
✨ New Features
- `client.subscribe()` now returns an observable with a `restart()` method that terminates the current link connection and recreates the request. ts const observable = client.subscribe({ query: subscription }); // Restart the connection to the link observable.restart();
- Subscription deduplication is now supported for the entire lifetime of a subscription connection (until a `complete` or `error` is received).
- `useSubscription`'s `restart` function now works with deduplicated subscriptions, restarting the shared connection.
🔧 Affected Symbols
ObservableQueryclient.subscribeobservable.restartuseSubscriptioncontext.queryDeduplication