diff --git a/.changeset/beige-geese-wink.md b/.changeset/beige-geese-wink.md deleted file mode 100644 index d92e77ccb9d..00000000000 --- a/.changeset/beige-geese-wink.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Decouple `canonicalStringify` from `ObjectCanon` for better time and memory performance. diff --git a/.changeset/breezy-spiders-tap.md b/.changeset/breezy-spiders-tap.md deleted file mode 100644 index a8af04cea0d..00000000000 --- a/.changeset/breezy-spiders-tap.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -"@apollo/client": patch ---- - -Add a `defaultContext` option and property on `ApolloClient`, e.g. for keeping track of changing auth tokens or dependency injection. - -This can be used e.g. in authentication scenarios, where a new token might be -generated outside of the link chain and should passed into the link chain. - -```js -import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client'; -import { setContext } from '@apollo/client/link/context'; - -const httpLink = createHttpLink({ - uri: '/graphql', -}); - -const authLink = setContext((_, { headers, token }) => { - return { - headers: { - ...headers, - authorization: token ? `Bearer ${token}` : "", - } - } -}); - -const client = new ApolloClient({ - link: authLink.concat(httpLink), - cache: new InMemoryCache() -}); - -// somewhere else in your application -function onNewToken(newToken) { - // token can now be changed for future requests without need for a global - // variable, scoped ref or recreating the client - client.defaultContext.token = newToken -} -``` diff --git a/.changeset/chatty-comics-yawn.md b/.changeset/chatty-comics-yawn.md deleted file mode 100644 index b50a939eda2..00000000000 --- a/.changeset/chatty-comics-yawn.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@apollo/client": patch ---- - -Adds a deprecation warning to the HOC and render prop APIs. - -The HOC and render prop APIs have already been deprecated since 2020, -but we previously didn't have a @deprecated tag in the DocBlocks. diff --git a/.changeset/clean-items-smash.md b/.changeset/clean-items-smash.md deleted file mode 100644 index c0111542c78..00000000000 --- a/.changeset/clean-items-smash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fix a potential memory leak in `FragmentRegistry.transform` and `FragmentRegistry.findFragmentSpreads` that would hold on to passed-in `DocumentNodes` for too long. diff --git a/.changeset/cold-llamas-turn.md b/.changeset/cold-llamas-turn.md deleted file mode 100644 index a3f1e0099df..00000000000 --- a/.changeset/cold-llamas-turn.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@apollo/client": patch ---- - -`parse` function: improve memory management -* use LRU `WeakCache` instead of `Map` to keep a limited number of parsed results -* cache is initiated lazily, only when needed -* expose `parse.resetCache()` method diff --git a/.changeset/curvy-seas-hope.md b/.changeset/curvy-seas-hope.md deleted file mode 100644 index 65491ac6318..00000000000 --- a/.changeset/curvy-seas-hope.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -"@apollo/client": minor ---- - -Simplify RetryLink, fix potential memory leak - -Historically, `RetryLink` would keep a `values` array of all previous values, -in case the operation would get an additional subscriber at a later point in time. -In practice, this could lead to a memory leak (#11393) and did not serve any -further purpose, as the resulting observable would only be subscribed to by -Apollo Client itself, and only once - it would be wrapped in a `Concast` before -being exposed to the user, and that `Concast` would handle subscribers on its -own. diff --git a/.changeset/dirty-kids-crash.md b/.changeset/dirty-kids-crash.md deleted file mode 100644 index 504c049268d..00000000000 --- a/.changeset/dirty-kids-crash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -`documentTransform`: use `optimism` and `WeakCache` instead of directly storing data on the `Trie` diff --git a/.changeset/dirty-tigers-matter.md b/.changeset/dirty-tigers-matter.md deleted file mode 100644 index 1a5d4a9e195..00000000000 --- a/.changeset/dirty-tigers-matter.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -"@apollo/client": minor ---- - -Create a new `useQueryRefHandlers` hook that returns `refetch` and `fetchMore` functions for a given `queryRef`. This is useful to get access to handlers for a `queryRef` that was created by `createQueryPreloader` or when the handlers for a `queryRef` produced by a different component are inaccessible. - -```jsx -const MyComponent({ queryRef }) { - const { refetch, fetchMore } = useQueryRefHandlers(queryRef); - - // ... -} -``` diff --git a/.changeset/forty-cups-shop.md b/.changeset/forty-cups-shop.md deleted file mode 100644 index 2c576843fdd..00000000000 --- a/.changeset/forty-cups-shop.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Fixes a potential memory leak in `Concast` that might have been triggered when `Concast` was used outside of Apollo Client. diff --git a/.changeset/friendly-clouds-laugh.md b/.changeset/friendly-clouds-laugh.md deleted file mode 100644 index 3821053fa83..00000000000 --- a/.changeset/friendly-clouds-laugh.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@apollo/client": minor ---- - -To work around issues in React Server Components, especially with bundling for -the Next.js "edge" runtime we now use an external package to wrap `react` imports -instead of importing React directly. diff --git a/.changeset/hot-ducks-burn.md b/.changeset/hot-ducks-burn.md deleted file mode 100644 index c0f8ac1836c..00000000000 --- a/.changeset/hot-ducks-burn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Add a `resetCache` method to `DocumentTransform` and hook `InMemoryCache.addTypenameTransform` up to `InMemoryCache.gc` diff --git a/.changeset/late-rabbits-protect.md b/.changeset/late-rabbits-protect.md deleted file mode 100644 index 1494b569018..00000000000 --- a/.changeset/late-rabbits-protect.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@apollo/client': minor ---- - -Remove the need to call `retain` from `useLoadableQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you. - -Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed. diff --git a/.changeset/mighty-coats-check.md b/.changeset/mighty-coats-check.md deleted file mode 100644 index 0d80272f8a5..00000000000 --- a/.changeset/mighty-coats-check.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -"@apollo/client": minor ---- - -Allow returning `IGNORE` sentinel object from `optimisticResponse` functions to bail-out from the optimistic update. - -Consider this example: - -```jsx -const UPDATE_COMMENT = gql` - mutation UpdateComment($commentId: ID!, $commentContent: String!) { - updateComment(commentId: $commentId, content: $commentContent) { - id - __typename - content - } - } -`; - -function CommentPageWithData() { - const [mutate] = useMutation(UPDATE_COMMENT); - return ( - - mutate({ - variables: { commentId, commentContent }, - optimisticResponse: (vars, { IGNORE }) => { - if (commentContent === "foo") { - // conditionally bail out of optimistic updates - return IGNORE; - } - return { - updateComment: { - id: commentId, - __typename: "Comment", - content: commentContent - } - } - }, - }) - } - /> - ); -} -``` - -The `IGNORE` sentinel can be destructured from the second parameter in the callback function signature passed to `optimisticResponse`. diff --git a/.changeset/pink-apricots-yawn.md b/.changeset/pink-apricots-yawn.md deleted file mode 100644 index 6eec10853be..00000000000 --- a/.changeset/pink-apricots-yawn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": minor ---- - -Increase the default memory limits for `executeSelectionSet` and `executeSelectionSetArray`. diff --git a/.changeset/polite-avocados-warn.md b/.changeset/polite-avocados-warn.md deleted file mode 100644 index dd04015cf3d..00000000000 --- a/.changeset/polite-avocados-warn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -`print`: use `WeakCache` instead of `WeakMap` diff --git a/.changeset/quick-hats-marry.md b/.changeset/quick-hats-marry.md deleted file mode 100644 index 2667f0a9750..00000000000 --- a/.changeset/quick-hats-marry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -ensure `defaultContext` is also used for mutations and subscriptions diff --git a/.changeset/rare-snakes-melt.md b/.changeset/rare-snakes-melt.md deleted file mode 100644 index 6757b401a47..00000000000 --- a/.changeset/rare-snakes-melt.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -"@apollo/client": minor ---- - -Add the ability to start preloading a query outside React to begin fetching as early as possible. Call `createQueryPreloader` to create a `preloadQuery` function which can be called to start fetching a query. This returns a `queryRef` which is passed to `useReadQuery` and suspended until the query is done fetching. - -```tsx -const preloadQuery = createQueryPreloader(client); -const queryRef = preloadQuery(QUERY, { variables, ...otherOptions }); - -function App() { - return { - Loading}> - - - } -} - -function MyQuery() { - const { data } = useReadQuery(queryRef); - - // do something with data -} -``` diff --git a/.changeset/shaggy-ears-scream.md b/.changeset/shaggy-ears-scream.md deleted file mode 100644 index 3ec33bfab58..00000000000 --- a/.changeset/shaggy-ears-scream.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": minor ---- - -Prevent `QueryInfo#markResult` mutation of `result.data` and return cache data consistently whether complete or incomplete. diff --git a/.changeset/shaggy-sheep-pull.md b/.changeset/shaggy-sheep-pull.md deleted file mode 100644 index 9c4ac23123b..00000000000 --- a/.changeset/shaggy-sheep-pull.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -`QueryManager.transformCache`: use `WeakCache` instead of `WeakMap` diff --git a/.changeset/six-rocks-arrive.md b/.changeset/six-rocks-arrive.md deleted file mode 100644 index 19b433d8439..00000000000 --- a/.changeset/six-rocks-arrive.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Release changes from [`v3.8.10`](https://github.com/apollographql/apollo-client/releases/tag/v3.8.10) diff --git a/.changeset/sixty-boxes-rest.md b/.changeset/sixty-boxes-rest.md deleted file mode 100644 index cce6eb7a98a..00000000000 --- a/.changeset/sixty-boxes-rest.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@apollo/client": minor ---- - -`QueryManager.inFlightLinkObservables` now uses a strong `Trie` as an internal data structure. - -#### Warning: requires `@apollo/experimental-nextjs-app-support` update -If you are using `@apollo/experimental-nextjs-app-support`, you will need to update that to at least 0.5.2, as it accesses this internal data structure. diff --git a/.changeset/smooth-plums-shout.md b/.changeset/smooth-plums-shout.md deleted file mode 100644 index 909e07ede8f..00000000000 --- a/.changeset/smooth-plums-shout.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -ObservableQuery: prevent reporting results of previous queries if the variables changed since diff --git a/.changeset/sour-sheep-walk.md b/.changeset/sour-sheep-walk.md deleted file mode 100644 index b0270d5ee68..00000000000 --- a/.changeset/sour-sheep-walk.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@apollo/client": minor ---- - -Ability to dynamically match mocks - -Adds support for a new property `MockedResponse.variableMatcher`: a predicate function that accepts a `variables` param. If `true`, the `variables` will be passed into the `ResultFunction` to help dynamically build a response. diff --git a/.changeset/spicy-drinks-camp.md b/.changeset/spicy-drinks-camp.md deleted file mode 100644 index 24c9d189945..00000000000 --- a/.changeset/spicy-drinks-camp.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@apollo/client': patch ---- - -Address bundling issue introduced in [#11412](https://github.com/apollographql/apollo-client/pull/11412) where the `react/cache` internals ended up duplicated in the bundle. This was due to the fact that we had a `react/hooks` entrypoint that imported these files along with the newly introduced `createQueryPreloader` function, which lived outside of the `react/hooks` folder. diff --git a/.changeset/strong-terms-perform.md b/.changeset/strong-terms-perform.md deleted file mode 100644 index 6974100076e..00000000000 --- a/.changeset/strong-terms-perform.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -"@apollo/client": minor ---- - -Add multipart subscription network adapters for Relay and urql - -### Relay - -```tsx -import { createFetchMultipartSubscription } from "@apollo/client/utilities/subscriptions/relay"; -import { Environment, Network, RecordSource, Store } from "relay-runtime"; - -const fetchMultipartSubs = createFetchMultipartSubscription( - "http://localhost:4000" -); - -const network = Network.create(fetchQuery, fetchMultipartSubs); - -export const RelayEnvironment = new Environment({ - network, - store: new Store(new RecordSource()), -}); -``` - -### Urql - -```tsx -import { createFetchMultipartSubscription } from "@apollo/client/utilities/subscriptions/urql"; -import { Client, fetchExchange, subscriptionExchange } from "@urql/core"; - -const url = "http://localhost:4000"; - -const multipartSubscriptionForwarder = createFetchMultipartSubscription( - url -); - -const client = new Client({ - url, - exchanges: [ - fetchExchange, - subscriptionExchange({ - forwardSubscription: multipartSubscriptionForwarder, - }), - ], -}); -``` diff --git a/.changeset/swift-zoos-collect.md b/.changeset/swift-zoos-collect.md deleted file mode 100644 index b3e988b8f0a..00000000000 --- a/.changeset/swift-zoos-collect.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -"@apollo/client": minor ---- - -Adds a new `skipPollAttempt` callback function that's called whenever a refetch attempt occurs while polling. If the function returns `true`, the refetch is skipped and not reattempted until the next poll interval. This will solve the frequent use-case of disabling polling when the window is inactive. - -```ts -useQuery(QUERY, { - pollInterval: 1000, - skipPollAttempt: () => document.hidden // or !document.hasFocus() -}); -// or define it globally -new ApolloClient({ - defaultOptions: { - watchQuery: { - skipPollAttempt: () => document.hidden // or !document.hasFocus() - } - } -}) diff --git a/.changeset/thick-mice-collect.md b/.changeset/thick-mice-collect.md deleted file mode 100644 index 47ed2e58cfd..00000000000 --- a/.changeset/thick-mice-collect.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Clarify types of `EntityStore.makeCacheKey`. diff --git a/.changeset/thick-tips-cry.md b/.changeset/thick-tips-cry.md deleted file mode 100644 index 407513ec1c7..00000000000 --- a/.changeset/thick-tips-cry.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -"@apollo/client": patch ---- - -Persisted Query Link: improve memory management -* use LRU `WeakCache` instead of `WeakMap` to keep a limited number of hash results -* hash cache is initiated lazily, only when needed -* expose `persistedLink.resetHashCache()` method -* reset hash cache if the upstream server reports it doesn't accept persisted queries diff --git a/.changeset/thirty-ties-arrive.md b/.changeset/thirty-ties-arrive.md deleted file mode 100644 index c8a6fc22c86..00000000000 --- a/.changeset/thirty-ties-arrive.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -"@apollo/client": minor ---- - -Introduces a new `useLoadableQuery` hook. This hook works similarly to `useBackgroundQuery` in that it returns a `queryRef` that can be used to suspend a component via the `useReadQuery` hook. It provides a more ergonomic way to load the query during a user interaction (for example when wanting to preload some data) that would otherwise be clunky with `useBackgroundQuery`. - -```tsx -function App() { - const [loadQuery, queryRef, { refetch, fetchMore, reset }] = useLoadableQuery(query, options) - - return ( - <> - - }> - {queryRef && } - - - ); -} - -function Child({ queryRef }) { - const { data } = useReadQuery(queryRef) - - // ... -} -``` diff --git a/.changeset/tough-timers-begin.md b/.changeset/tough-timers-begin.md deleted file mode 100644 index 53fac70e002..00000000000 --- a/.changeset/tough-timers-begin.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@apollo/client": minor ---- - -Deprecates `canonizeResults`. - -Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option anymore. -A future version of Apollo Client will contain a similar feature without the risk of memory leaks. diff --git a/.changeset/unlucky-rats-decide.md b/.changeset/unlucky-rats-decide.md deleted file mode 100644 index 9be1d2d3961..00000000000 --- a/.changeset/unlucky-rats-decide.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -use WeakMap in React Native with Hermes diff --git a/.changeset/violet-lions-draw.md b/.changeset/violet-lions-draw.md deleted file mode 100644 index 6e5d046a6c9..00000000000 --- a/.changeset/violet-lions-draw.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -InMemoryCache.gc now also triggers FragmentRegistry.resetCaches (if there is a FragmentRegistry) diff --git a/.changeset/wet-forks-rhyme.md b/.changeset/wet-forks-rhyme.md deleted file mode 100644 index 2fc57066943..00000000000 --- a/.changeset/wet-forks-rhyme.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Adds an experimental `ApolloClient.getMemoryInternals` helper diff --git a/.changeset/wild-dolphins-jog.md b/.changeset/wild-dolphins-jog.md deleted file mode 100644 index 8030414fffe..00000000000 --- a/.changeset/wild-dolphins-jog.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": patch ---- - -Add `reset` method to `print`, hook up to `InMemoryCache.gc` diff --git a/.changeset/wise-news-grab.md b/.changeset/wise-news-grab.md deleted file mode 100644 index 83eafb1375f..00000000000 --- a/.changeset/wise-news-grab.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@apollo/client': minor ---- - -Remove the need to call `retain` from `useBackgroundQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you. - -Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed. diff --git a/.changeset/yellow-flies-repeat.md b/.changeset/yellow-flies-repeat.md deleted file mode 100644 index b6fcff7db25..00000000000 --- a/.changeset/yellow-flies-repeat.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@apollo/client": minor ---- - -Support re-using of mocks in the MockedProvider diff --git a/CHANGELOG.md b/CHANGELOG.md index 341779e9754..399686ebdc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,73 +1,95 @@ # @apollo/client -## 3.9.0-rc.1 +## 3.9.0 -### Patch Changes +### Minor Changes -- [#11503](https://github.com/apollographql/apollo-client/pull/11503) [`67f62e3`](https://github.com/apollographql/apollo-client/commit/67f62e359bc471787d066319326e5582b4a635c8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Release changes from [`v3.8.10`](https://github.com/apollographql/apollo-client/releases/tag/v3.8.10) +#### Memory optimizations -## 3.8.10 +- [#11424](https://github.com/apollographql/apollo-client/pull/11424) [`62f3b6d`](https://github.com/apollographql/apollo-client/commit/62f3b6d0e89611e27d9f29812ee60e5db5963fd6) Thanks [@phryneas](https://github.com/phryneas)! - Simplify RetryLink, fix potential memory leak -### Patch Changes + Historically, `RetryLink` would keep a `values` array of all previous values, in case the operation would get an additional subscriber at a later point in time. -- [#11489](https://github.com/apollographql/apollo-client/pull/11489) [`abfd02a`](https://github.com/apollographql/apollo-client/commit/abfd02abeb8585e44377e9e87e5d20e5d95be002) Thanks [@gronxb](https://github.com/gronxb)! - Fix `networkStatus` with `useSuspenseQuery` not properly updating to ready state when using a `cache-and-network` fetch policy that returns data equal to what is already in the cache. + In practice, this could lead to a memory leak ([#11393](https://github.com/apollographql/apollo-client/pull/11393)) and did not serve any further purpose, as the resulting observable would only be subscribed to by Apollo Client itself, and only once - it would be wrapped in a `Concast` before being exposed to the user, and that `Concast` would handle subscribers on its own. -- [#11483](https://github.com/apollographql/apollo-client/pull/11483) [`6394dda`](https://github.com/apollographql/apollo-client/commit/6394dda47fa83d9ddd922e0d05e62bd872e4ea8e) Thanks [@pipopotamasu](https://github.com/pipopotamasu)! - Fix cache override warning output +- [#11435](https://github.com/apollographql/apollo-client/pull/11435) [`5cce53e`](https://github.com/apollographql/apollo-client/commit/5cce53e83b976f85d2d2b06e28cc38f01324fea1) Thanks [@phryneas](https://github.com/phryneas)! - Deprecates `canonizeResults`. -## 3.9.0-rc.0 + Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option anymore. A future version of Apollo Client will contain a similar feature without the risk of memory leaks. -### Minor Changes +- [#11254](https://github.com/apollographql/apollo-client/pull/11254) [`d08970d`](https://github.com/apollographql/apollo-client/commit/d08970d348cf4ad6d80c6baf85b4a4cd4034a3bb) Thanks [@benjamn](https://github.com/benjamn)! - Decouple `canonicalStringify` from `ObjectCanon` for better time and memory performance. -- [#11495](https://github.com/apollographql/apollo-client/pull/11495) [`1190aa5`](https://github.com/apollographql/apollo-client/commit/1190aa59a106217f7192c1f81099adfa5e4365c1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Increase the default memory limits for `executeSelectionSet` and `executeSelectionSetArray`. +- [#11356](https://github.com/apollographql/apollo-client/pull/11356) [`cc4ac7e`](https://github.com/apollographql/apollo-client/commit/cc4ac7e1917f046bcd177882727864eed40b910e) Thanks [@phryneas](https://github.com/phryneas)! - Fix a potential memory leak in `FragmentRegistry.transform` and `FragmentRegistry.findFragmentSpreads` that would hold on to passed-in `DocumentNodes` for too long. -## 3.8.9 +- [#11370](https://github.com/apollographql/apollo-client/pull/11370) [`25e2cb4`](https://github.com/apollographql/apollo-client/commit/25e2cb431c76ec5aa88202eaacbd98fad42edc7f) Thanks [@phryneas](https://github.com/phryneas)! - `parse` function: improve memory management -### Patch Changes + - use LRU `WeakCache` instead of `Map` to keep a limited number of parsed results + - cache is initiated lazily, only when needed + - expose `parse.resetCache()` method -- [#11472](https://github.com/apollographql/apollo-client/pull/11472) [`afc844d`](https://github.com/apollographql/apollo-client/commit/afc844dd8d6f9f7a3e2003f9a5b541291dfe3fb4) Thanks [@alessbell](https://github.com/alessbell)! - Fix delay: Infinity when set on a MockResponse passed to Mocked Provider so it indefinitely enters loading state. +- [#11389](https://github.com/apollographql/apollo-client/pull/11389) [`139acd1`](https://github.com/apollographql/apollo-client/commit/139acd1153afa1445b69dcb4e139668ab8c5889a) Thanks [@phryneas](https://github.com/phryneas)! - `documentTransform`: use `optimism` and `WeakCache` instead of directly storing data on the `Trie` -- [#11464](https://github.com/apollographql/apollo-client/pull/11464) [`aac12b2`](https://github.com/apollographql/apollo-client/commit/aac12b221a6cb776d4941b6c8aadf04f0f0acd27) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Prevent `useFragment` from excessively unsubscribing and resubscribing the fragment with the cache on every render. +- [#11358](https://github.com/apollographql/apollo-client/pull/11358) [`7d939f8`](https://github.com/apollographql/apollo-client/commit/7d939f80fbc2c419c58a6c55b6a35ee7474d0379) Thanks [@phryneas](https://github.com/phryneas)! - Fixes a potential memory leak in `Concast` that might have been triggered when `Concast` was used outside of Apollo Client. -- [#11449](https://github.com/apollographql/apollo-client/pull/11449) [`f40cda4`](https://github.com/apollographql/apollo-client/commit/f40cda45841e93b056c781c19651b54464f7346a) Thanks [@phryneas](https://github.com/phryneas)! - Removes refences to the typescript "dom" lib. +- [#11344](https://github.com/apollographql/apollo-client/pull/11344) [`bd26676`](https://github.com/apollographql/apollo-client/commit/bd2667619700139af32a45364794d11f845ab6cf) Thanks [@phryneas](https://github.com/phryneas)! - Add a `resetCache` method to `DocumentTransform` and hook `InMemoryCache.addTypenameTransform` up to `InMemoryCache.gc` -- [#11470](https://github.com/apollographql/apollo-client/pull/11470) [`e293bc9`](https://github.com/apollographql/apollo-client/commit/e293bc90d6f7937a6fc7c169f7b16eeb39d5fd49) Thanks [@phryneas](https://github.com/phryneas)! - Remove an unnecessary check from parseAndCheckHttpResponse. +- [#11367](https://github.com/apollographql/apollo-client/pull/11367) [`30d17bf`](https://github.com/apollographql/apollo-client/commit/30d17bfebe44dbfa7b78c8982cfeb49afd37129c) Thanks [@phryneas](https://github.com/phryneas)! - `print`: use `WeakCache` instead of `WeakMap` -## 3.9.0-beta.1 +- [#11387](https://github.com/apollographql/apollo-client/pull/11387) [`4dce867`](https://github.com/apollographql/apollo-client/commit/4dce8673b1757d8a3a4edd2996d780e86fad14e3) Thanks [@phryneas](https://github.com/phryneas)! - `QueryManager.transformCache`: use `WeakCache` instead of `WeakMap` -### Minor Changes +- [#11369](https://github.com/apollographql/apollo-client/pull/11369) [`2a47164`](https://github.com/apollographql/apollo-client/commit/2a471646616e3af1b5c039e961f8d5717fad8f32) Thanks [@phryneas](https://github.com/phryneas)! - Persisted Query Link: improve memory management -- [#11424](https://github.com/apollographql/apollo-client/pull/11424) [`62f3b6d`](https://github.com/apollographql/apollo-client/commit/62f3b6d0e89611e27d9f29812ee60e5db5963fd6) Thanks [@phryneas](https://github.com/phryneas)! - Simplify RetryLink, fix potential memory leak + - use LRU `WeakCache` instead of `WeakMap` to keep a limited number of hash results + - hash cache is initiated lazily, only when needed + - expose `persistedLink.resetHashCache()` method + - reset hash cache if the upstream server reports it doesn't accept persisted queries - Historically, `RetryLink` would keep a `values` array of all previous values, - in case the operation would get an additional subscriber at a later point in time. - In practice, this could lead to a memory leak (#11393) and did not serve any - further purpose, as the resulting observable would only be subscribed to by - Apollo Client itself, and only once - it would be wrapped in a `Concast` before - being exposed to the user, and that `Concast` would handle subscribers on its - own. +- [#10804](https://github.com/apollographql/apollo-client/pull/10804) [`221dd99`](https://github.com/apollographql/apollo-client/commit/221dd99ffd1990f8bd0392543af35e9b08d0fed8) Thanks [@phryneas](https://github.com/phryneas)! - use WeakMap in React Native with Hermes -- [#11442](https://github.com/apollographql/apollo-client/pull/11442) [`4b6f2bc`](https://github.com/apollographql/apollo-client/commit/4b6f2bccf3ba94643b38689b32edd2839e47aec1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the need to call `retain` from `useLoadableQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you. +- [#11355](https://github.com/apollographql/apollo-client/pull/11355) [`7d8e184`](https://github.com/apollographql/apollo-client/commit/7d8e18493cd13134726c6643cbf0fadb08be2d37) Thanks [@phryneas](https://github.com/phryneas)! - InMemoryCache.gc now also triggers FragmentRegistry.resetCaches (if there is a FragmentRegistry) - Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed. +- [#11409](https://github.com/apollographql/apollo-client/pull/11409) [`2e7203b`](https://github.com/apollographql/apollo-client/commit/2e7203b3a9618952ddb522627ded7cceabd7f250) Thanks [@phryneas](https://github.com/phryneas)! - Adds an experimental `ApolloClient.getMemoryInternals` helper -- [#11438](https://github.com/apollographql/apollo-client/pull/11438) [`6d46ab9`](https://github.com/apollographql/apollo-client/commit/6d46ab930a5e9bd5cae153d3b75b8966784fcd4e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the need to call `retain` from `useBackgroundQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you. +- [#11343](https://github.com/apollographql/apollo-client/pull/11343) [`776631d`](https://github.com/apollographql/apollo-client/commit/776631de4500d56252f6f5fdaf29a81c41dfbdc7) Thanks [@phryneas](https://github.com/phryneas)! - Add `reset` method to `print`, hook up to `InMemoryCache.gc` - Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed. +#### Suspense-enabled data fetching on user interaction with `useLoadableQuery` -### Patch Changes +- [#11300](https://github.com/apollographql/apollo-client/pull/11300) [`a815873`](https://github.com/apollographql/apollo-client/commit/a8158733cfa3e65180ec23518d657ea41894bb2b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Introduces a new `useLoadableQuery` hook. This hook works similarly to `useBackgroundQuery` in that it returns a `queryRef` that can be used to suspend a component via the `useReadQuery` hook. It provides a more ergonomic way to load the query during a user interaction (for example when wanting to preload some data) that would otherwise be clunky with `useBackgroundQuery`. -- [#11443](https://github.com/apollographql/apollo-client/pull/11443) [`ff5a332`](https://github.com/apollographql/apollo-client/commit/ff5a332ff8b190c418df25371e36719d70061ebe) Thanks [@phryneas](https://github.com/phryneas)! - Adds a deprecation warning to the HOC and render prop APIs. + ```tsx + function App() { + const [loadQuery, queryRef, { refetch, fetchMore, reset }] = + useLoadableQuery(query, options); - The HOC and render prop APIs have already been deprecated since 2020, - but we previously didn't have a @deprecated tag in the DocBlocks. + return ( + <> + + }> + {queryRef && } + + + ); + } -- [#11078](https://github.com/apollographql/apollo-client/pull/11078) [`14edebe`](https://github.com/apollographql/apollo-client/commit/14edebebefb7634c32b921d02c1c85c6c8737989) Thanks [@phryneas](https://github.com/phryneas)! - ObservableQuery: prevent reporting results of previous queries if the variables changed since + function Child({ queryRef }) { + const { data } = useReadQuery(queryRef); -- [#11439](https://github.com/apollographql/apollo-client/pull/11439) [`33454f0`](https://github.com/apollographql/apollo-client/commit/33454f0a40a05ea2b00633bda20a84d0ec3a4f4d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Address bundling issue introduced in [#11412](https://github.com/apollographql/apollo-client/pull/11412) where the `react/cache` internals ended up duplicated in the bundle. This was due to the fact that we had a `react/hooks` entrypoint that imported these files along with the newly introduced `createQueryPreloader` function, which lived outside of the `react/hooks` folder. + // ... + } + ``` -## 3.9.0-beta.0 +#### Begin preloading outside of React with `createQueryPreloader` -### Minor Changes +- [#11412](https://github.com/apollographql/apollo-client/pull/11412) [`58db5c3`](https://github.com/apollographql/apollo-client/commit/58db5c3295b88162f91019f0898f6baa4b9cced6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the ability to start preloading a query outside React to begin fetching as early as possible. Call `createQueryPreloader` to create a `preloadQuery` function which can be called to start fetching a query. This returns a `queryRef` which is passed to `useReadQuery` and suspended until the query is done fetching. + +#### Testing utility improvements + +- [#11178](https://github.com/apollographql/apollo-client/pull/11178) [`4d64a6f`](https://github.com/apollographql/apollo-client/commit/4d64a6fa2ad5abe6f7f172c164f5e1fc2cb89829) Thanks [@sebakerckhof](https://github.com/sebakerckhof)! - Support re-using of mocks in the MockedProvider + +- [#6701](https://github.com/apollographql/apollo-client/pull/6701) [`8d2b4e1`](https://github.com/apollographql/apollo-client/commit/8d2b4e107d7c21563894ced3a65d631183b58fd9) Thanks [@prowe](https://github.com/prowe)! - Ability to dynamically match mocks + + Adds support for a new property `MockedResponse.variableMatcher`: a predicate function that accepts a `variables` param. If `true`, the `variables` will be passed into the `ResultFunction` to help dynamically build a response. + +#### New `useQueryRefHandlers` hook - [#11412](https://github.com/apollographql/apollo-client/pull/11412) [`58db5c3`](https://github.com/apollographql/apollo-client/commit/58db5c3295b88162f91019f0898f6baa4b9cced6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Create a new `useQueryRefHandlers` hook that returns `refetch` and `fetchMore` functions for a given `queryRef`. This is useful to get access to handlers for a `queryRef` that was created by `createQueryPreloader` or when the handlers for a `queryRef` produced by a different component are inaccessible. @@ -79,6 +101,8 @@ } ``` +#### Bail out of `optimisticResponse` updates with the `IGNORE` sentinel object + - [#11410](https://github.com/apollographql/apollo-client/pull/11410) [`07fcf6a`](https://github.com/apollographql/apollo-client/commit/07fcf6a3bf5bc78ffe6f3e598897246b4da02cbb) Thanks [@sf-twingate](https://github.com/sf-twingate)! - Allow returning `IGNORE` sentinel object from `optimisticResponse` functions to bail-out from the optimistic update. Consider this example: @@ -123,8 +147,6 @@ The `IGNORE` sentinel can be destructured from the second parameter in the callback function signature passed to `optimisticResponse`. -- [#11412](https://github.com/apollographql/apollo-client/pull/11412) [`58db5c3`](https://github.com/apollographql/apollo-client/commit/58db5c3295b88162f91019f0898f6baa4b9cced6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the ability to start preloading a query outside React to begin fetching as early as possible. Call `createQueryPreloader` to create a `preloadQuery` function which can be called to start fetching a query. This returns a `queryRef` which is passed to `useReadQuery` and suspended until the query is done fetching. - ```tsx const preloadQuery = createQueryPreloader(client); const queryRef = preloadQuery(QUERY, { variables, ...otherOptions }); @@ -144,130 +166,11 @@ } ``` -- [#11397](https://github.com/apollographql/apollo-client/pull/11397) [`3f7eecb`](https://github.com/apollographql/apollo-client/commit/3f7eecbfbd4f4444cffcaac7dd9fd225c8c2a401) Thanks [@aditya-kumawat](https://github.com/aditya-kumawat)! - Adds a new `skipPollAttempt` callback function that's called whenever a refetch attempt occurs while polling. If the function returns `true`, the refetch is skipped and not reattempted until the next poll interval. This will solve the frequent use-case of disabling polling when the window is inactive. - - ```ts - useQuery(QUERY, { - pollInterval: 1000, - skipPollAttempt: () => document.hidden, // or !document.hasFocus() - }); - // or define it globally - new ApolloClient({ - defaultOptions: { - watchQuery: { - skipPollAttempt: () => document.hidden, // or !document.hasFocus() - }, - }, - }); - ``` - -- [#11435](https://github.com/apollographql/apollo-client/pull/11435) [`5cce53e`](https://github.com/apollographql/apollo-client/commit/5cce53e83b976f85d2d2b06e28cc38f01324fea1) Thanks [@phryneas](https://github.com/phryneas)! - Deprecates `canonizeResults`. - - Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option anymore. - A future version of Apollo Client will contain a similar feature without the risk of memory leaks. - -### Patch Changes - -- [#11369](https://github.com/apollographql/apollo-client/pull/11369) [`2a47164`](https://github.com/apollographql/apollo-client/commit/2a471646616e3af1b5c039e961f8d5717fad8f32) Thanks [@phryneas](https://github.com/phryneas)! - Persisted Query Link: improve memory management - - - use LRU `WeakCache` instead of `WeakMap` to keep a limited number of hash results - - hash cache is initiated lazily, only when needed - - expose `persistedLink.resetHashCache()` method - - reset hash cache if the upstream server reports it doesn't accept persisted queries - -- [#10804](https://github.com/apollographql/apollo-client/pull/10804) [`221dd99`](https://github.com/apollographql/apollo-client/commit/221dd99ffd1990f8bd0392543af35e9b08d0fed8) Thanks [@phryneas](https://github.com/phryneas)! - use WeakMap in React Native with Hermes - -- [#11409](https://github.com/apollographql/apollo-client/pull/11409) [`2e7203b`](https://github.com/apollographql/apollo-client/commit/2e7203b3a9618952ddb522627ded7cceabd7f250) Thanks [@phryneas](https://github.com/phryneas)! - Adds an experimental `ApolloClient.getMemoryInternals` helper - -## 3.9.0-alpha.5 - -### Minor Changes - -- [#11345](https://github.com/apollographql/apollo-client/pull/11345) [`1759066a8`](https://github.com/apollographql/apollo-client/commit/1759066a8f9a204e49228568aef9446a64890ff3) Thanks [@phryneas](https://github.com/phryneas)! - `QueryManager.inFlightLinkObservables` now uses a strong `Trie` as an internal data structure. +#### Network adapters for multipart subscriptions usage with Relay and urql - #### Warning: requires `@apollo/experimental-nextjs-app-support` update - - If you are using `@apollo/experimental-nextjs-app-support`, you will need to update that to at least 0.5.2, as it accesses this internal data structure. +- [#11301](https://github.com/apollographql/apollo-client/pull/11301) [`46ab032`](https://github.com/apollographql/apollo-client/commit/46ab032af83a01f184bfcce5edba4b55dbb2962a) Thanks [@alessbell](https://github.com/alessbell)! - Add multipart subscription network adapters for Relay and urql -- [#11300](https://github.com/apollographql/apollo-client/pull/11300) [`a8158733c`](https://github.com/apollographql/apollo-client/commit/a8158733cfa3e65180ec23518d657ea41894bb2b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Introduces a new `useLoadableQuery` hook. This hook works similarly to `useBackgroundQuery` in that it returns a `queryRef` that can be used to suspend a component via the `useReadQuery` hook. It provides a more ergonomic way to load the query during a user interaction (for example when wanting to preload some data) that would otherwise be clunky with `useBackgroundQuery`. - - ```tsx - function App() { - const [loadQuery, queryRef, { refetch, fetchMore, reset }] = - useLoadableQuery(query, options); - - return ( - <> - - }> - {queryRef && } - - - ); - } - - function Child({ queryRef }) { - const { data } = useReadQuery(queryRef); - - // ... - } - ``` - -### Patch Changes - -- [#11356](https://github.com/apollographql/apollo-client/pull/11356) [`cc4ac7e19`](https://github.com/apollographql/apollo-client/commit/cc4ac7e1917f046bcd177882727864eed40b910e) Thanks [@phryneas](https://github.com/phryneas)! - Fix a potential memory leak in `FragmentRegistry.transform` and `FragmentRegistry.findFragmentSpreads` that would hold on to passed-in `DocumentNodes` for too long. - -- [#11370](https://github.com/apollographql/apollo-client/pull/11370) [`25e2cb431`](https://github.com/apollographql/apollo-client/commit/25e2cb431c76ec5aa88202eaacbd98fad42edc7f) Thanks [@phryneas](https://github.com/phryneas)! - `parse` function: improve memory management - - - use LRU `WeakCache` instead of `Map` to keep a limited number of parsed results - - cache is initiated lazily, only when needed - - expose `parse.resetCache()` method - -- [#11389](https://github.com/apollographql/apollo-client/pull/11389) [`139acd115`](https://github.com/apollographql/apollo-client/commit/139acd1153afa1445b69dcb4e139668ab8c5889a) Thanks [@phryneas](https://github.com/phryneas)! - `documentTransform`: use `optimism` and `WeakCache` instead of directly storing data on the `Trie` - -- [#11358](https://github.com/apollographql/apollo-client/pull/11358) [`7d939f80f`](https://github.com/apollographql/apollo-client/commit/7d939f80fbc2c419c58a6c55b6a35ee7474d0379) Thanks [@phryneas](https://github.com/phryneas)! - Fixes a potential memory leak in `Concast` that might have been triggered when `Concast` was used outside of Apollo Client. - -- [#11344](https://github.com/apollographql/apollo-client/pull/11344) [`bd2667619`](https://github.com/apollographql/apollo-client/commit/bd2667619700139af32a45364794d11f845ab6cf) Thanks [@phryneas](https://github.com/phryneas)! - Add a `resetCache` method to `DocumentTransform` and hook `InMemoryCache.addTypenameTransform` up to `InMemoryCache.gc` - -- [#11367](https://github.com/apollographql/apollo-client/pull/11367) [`30d17bfeb`](https://github.com/apollographql/apollo-client/commit/30d17bfebe44dbfa7b78c8982cfeb49afd37129c) Thanks [@phryneas](https://github.com/phryneas)! - `print`: use `WeakCache` instead of `WeakMap` - -- [#11385](https://github.com/apollographql/apollo-client/pull/11385) [`d9ca4f082`](https://github.com/apollographql/apollo-client/commit/d9ca4f0821c66ae4f03cf35a7ac93fe604cc6de3) Thanks [@phryneas](https://github.com/phryneas)! - ensure `defaultContext` is also used for mutations and subscriptions - -- [#11387](https://github.com/apollographql/apollo-client/pull/11387) [`4dce8673b`](https://github.com/apollographql/apollo-client/commit/4dce8673b1757d8a3a4edd2996d780e86fad14e3) Thanks [@phryneas](https://github.com/phryneas)! - `QueryManager.transformCache`: use `WeakCache` instead of `WeakMap` - -- [#11371](https://github.com/apollographql/apollo-client/pull/11371) [`ebd8fe2c1`](https://github.com/apollographql/apollo-client/commit/ebd8fe2c1b8b50bfeb2da20aeca5671300fb5564) Thanks [@phryneas](https://github.com/phryneas)! - Clarify types of `EntityStore.makeCacheKey`. - -- [#11355](https://github.com/apollographql/apollo-client/pull/11355) [`7d8e18493`](https://github.com/apollographql/apollo-client/commit/7d8e18493cd13134726c6643cbf0fadb08be2d37) Thanks [@phryneas](https://github.com/phryneas)! - InMemoryCache.gc now also triggers FragmentRegistry.resetCaches (if there is a FragmentRegistry) - -## 3.8.8 - -### Patch Changes - -- [#11200](https://github.com/apollographql/apollo-client/pull/11200) [`ae5091a21`](https://github.com/apollographql/apollo-client/commit/ae5091a21f0feff1486503071ea8dc002cf1be41) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Enable `strict` in tsconfig for the entire project. - -- [#11332](https://github.com/apollographql/apollo-client/pull/11332) [`291aea56b`](https://github.com/apollographql/apollo-client/commit/291aea56bfaed3987a98be7fe4e6160114b62d2d) Thanks [@asvishnyakov](https://github.com/asvishnyakov)! - Add missed reexports of MutationFetchPolicy and RefetchWritePolicy to @apollo/client/core - -- [#10931](https://github.com/apollographql/apollo-client/pull/10931) [`e5acf910e`](https://github.com/apollographql/apollo-client/commit/e5acf910e39752b453540b6751046d1c19b66350) Thanks [@phryneas](https://github.com/phryneas)! - `useMutation`: also reset internal state on reset - -## 3.9.0-alpha.4 - -### Minor Changes - -- [#11175](https://github.com/apollographql/apollo-client/pull/11175) [`d6d14911c`](https://github.com/apollographql/apollo-client/commit/d6d14911c40782cd6d69167b6f6169c890091ccb) Thanks [@phryneas](https://github.com/phryneas)! - To work around issues in React Server Components, especially with bundling for - the Next.js "edge" runtime we now use an external package to wrap `react` imports - instead of importing React directly. - -### Patch Changes - -- [#11343](https://github.com/apollographql/apollo-client/pull/11343) [`776631de4`](https://github.com/apollographql/apollo-client/commit/776631de4500d56252f6f5fdaf29a81c41dfbdc7) Thanks [@phryneas](https://github.com/phryneas)! - Add `reset` method to `print`, hook up to `InMemoryCache.gc` - -## 3.9.0-alpha.3 - -### Minor Changes - -- [#11301](https://github.com/apollographql/apollo-client/pull/11301) [`46ab032af`](https://github.com/apollographql/apollo-client/commit/46ab032af83a01f184bfcce5edba4b55dbb2962a) Thanks [@alessbell](https://github.com/alessbell)! - Add multipart subscription network adapters for Relay and urql - - ### Relay + ##### Relay ```tsx import { createFetchMultipartSubscription } from "@apollo/client/utilities/subscriptions/relay"; @@ -285,7 +188,7 @@ }); ``` - ### Urql + ##### Urql ```tsx import { createFetchMultipartSubscription } from "@apollo/client/utilities/subscriptions/urql"; @@ -306,12 +209,60 @@ }); ``` -### Patch Changes +#### `skipPollAttempt` callback function + +- [#11397](https://github.com/apollographql/apollo-client/pull/11397) [`3f7eecb`](https://github.com/apollographql/apollo-client/commit/3f7eecbfbd4f4444cffcaac7dd9fd225c8c2a401) Thanks [@aditya-kumawat](https://github.com/aditya-kumawat)! - Adds a new `skipPollAttempt` callback function that's called whenever a refetch attempt occurs while polling. If the function returns `true`, the refetch is skipped and not reattempted until the next poll interval. This will solve the frequent use-case of disabling polling when the window is inactive. + + ```ts + useQuery(QUERY, { + pollInterval: 1000, + skipPollAttempt: () => document.hidden, // or !document.hasFocus() + }); + // or define it globally + new ApolloClient({ + defaultOptions: { + watchQuery: { + skipPollAttempt: () => document.hidden, // or !document.hasFocus() + }, + }, + }); + ``` + +#### `QueryManager.inFlightLinkObservables` now uses a strong `Trie` as an internal data structure -- [#11275](https://github.com/apollographql/apollo-client/pull/11275) [`3862f9ba9`](https://github.com/apollographql/apollo-client/commit/3862f9ba9086394c4cf4c2ecd99e8e0f6cf44885) Thanks [@phryneas](https://github.com/phryneas)! - Add a `defaultContext` option and property on `ApolloClient`, e.g. for keeping track of changing auth tokens or dependency injection. +- [#11345](https://github.com/apollographql/apollo-client/pull/11345) [`1759066`](https://github.com/apollographql/apollo-client/commit/1759066a8f9a204e49228568aef9446a64890ff3) Thanks [@phryneas](https://github.com/phryneas)! - This can be used e.g. in authentication scenarios, where a new token might be - generated outside of the link chain and should passed into the link chain. + ##### Warning: requires `@apollo/experimental-nextjs-app-support` update + + If you are using `@apollo/experimental-nextjs-app-support`, you will need to update that to at least 0.5.2, as it accesses this internal data structure. + +
+

More Minor Changes

+ +- [#11202](https://github.com/apollographql/apollo-client/pull/11202) [`7c2bc08`](https://github.com/apollographql/apollo-client/commit/7c2bc08b2ab46b9aa181d187a27aec2ad7129599) Thanks [@benjamn](https://github.com/benjamn)! - Prevent `QueryInfo#markResult` mutation of `result.data` and return cache data consistently whether complete or incomplete. + +- [#11442](https://github.com/apollographql/apollo-client/pull/11442) [`4b6f2bc`](https://github.com/apollographql/apollo-client/commit/4b6f2bccf3ba94643b38689b32edd2839e47aec1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the need to call `retain` from `useLoadableQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you. + + Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed. + +- [#11438](https://github.com/apollographql/apollo-client/pull/11438) [`6d46ab9`](https://github.com/apollographql/apollo-client/commit/6d46ab930a5e9bd5cae153d3b75b8966784fcd4e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the need to call `retain` from `useBackgroundQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you. + + Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed. + +- [#11175](https://github.com/apollographql/apollo-client/pull/11175) [`d6d1491`](https://github.com/apollographql/apollo-client/commit/d6d14911c40782cd6d69167b6f6169c890091ccb) Thanks [@phryneas](https://github.com/phryneas)! - To work around issues in React Server Components, especially with bundling for + the Next.js "edge" runtime we now use an external package to wrap `react` imports + instead of importing React directly. + +- [#11495](https://github.com/apollographql/apollo-client/pull/11495) [`1190aa5`](https://github.com/apollographql/apollo-client/commit/1190aa59a106217f7192c1f81099adfa5e4365c1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Increase the default memory limits for `executeSelectionSet` and `executeSelectionSetArray`. + +
+ +
+

Patch Changes

+ +- [#11275](https://github.com/apollographql/apollo-client/pull/11275) [`3862f9b`](https://github.com/apollographql/apollo-client/commit/3862f9ba9086394c4cf4c2ecd99e8e0f6cf44885) Thanks [@phryneas](https://github.com/phryneas)! - Add a `defaultContext` option and property on `ApolloClient`, e.g. for keeping track of changing auth tokens or dependency injection. + + This can be used e.g. in authentication scenarios, where a new token might be generated outside of the link chain and should passed into the link chain. ```js import { ApolloClient, createHttpLink, InMemoryCache } from "@apollo/client"; @@ -343,29 +294,52 @@ } ``` -- [#11297](https://github.com/apollographql/apollo-client/pull/11297) [`c8c76a522`](https://github.com/apollographql/apollo-client/commit/c8c76a522e593de0d06cff73fde2d9e88152bed6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add an explicit return type for the `useReadQuery` hook called `UseReadQueryResult`. Previously the return type of this hook was inferred from the return value. +- [#11443](https://github.com/apollographql/apollo-client/pull/11443) [`ff5a332`](https://github.com/apollographql/apollo-client/commit/ff5a332ff8b190c418df25371e36719d70061ebe) Thanks [@phryneas](https://github.com/phryneas)! - Adds a deprecation warning to the HOC and render prop APIs. -## 3.9.0-alpha.2 + The HOC and render prop APIs have already been deprecated since 2020, + but we previously didn't have a `@deprecated` tag in the DocBlocks. + +- [#11385](https://github.com/apollographql/apollo-client/pull/11385) [`d9ca4f0`](https://github.com/apollographql/apollo-client/commit/d9ca4f0821c66ae4f03cf35a7ac93fe604cc6de3) Thanks [@phryneas](https://github.com/phryneas)! - ensure `defaultContext` is also used for mutations and subscriptions + +- [#11503](https://github.com/apollographql/apollo-client/pull/11503) [`67f62e3`](https://github.com/apollographql/apollo-client/commit/67f62e359bc471787d066319326e5582b4a635c8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Release changes from [`v3.8.10`](https://github.com/apollographql/apollo-client/releases/tag/v3.8.10) + +- [#11078](https://github.com/apollographql/apollo-client/pull/11078) [`14edebe`](https://github.com/apollographql/apollo-client/commit/14edebebefb7634c32b921d02c1c85c6c8737989) Thanks [@phryneas](https://github.com/phryneas)! - ObservableQuery: prevent reporting results of previous queries if the variables changed since + +- [#11439](https://github.com/apollographql/apollo-client/pull/11439) [`33454f0`](https://github.com/apollographql/apollo-client/commit/33454f0a40a05ea2b00633bda20a84d0ec3a4f4d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Address bundling issue introduced in [#11412](https://github.com/apollographql/apollo-client/pull/11412) where the `react/cache` internals ended up duplicated in the bundle. This was due to the fact that we had a `react/hooks` entrypoint that imported these files along with the newly introduced `createQueryPreloader` function, which lived outside of the `react/hooks` folder. + +- [#11371](https://github.com/apollographql/apollo-client/pull/11371) [`ebd8fe2`](https://github.com/apollographql/apollo-client/commit/ebd8fe2c1b8b50bfeb2da20aeca5671300fb5564) Thanks [@phryneas](https://github.com/phryneas)! - Clarify types of `EntityStore.makeCacheKey`. + +
+ +## 3.8.10 ### Patch Changes -- [#11254](https://github.com/apollographql/apollo-client/pull/11254) [`d08970d34`](https://github.com/apollographql/apollo-client/commit/d08970d348cf4ad6d80c6baf85b4a4cd4034a3bb) Thanks [@benjamn](https://github.com/benjamn)! - Decouple `canonicalStringify` from `ObjectCanon` for better time and memory performance. +- [#11489](https://github.com/apollographql/apollo-client/pull/11489) [`abfd02a`](https://github.com/apollographql/apollo-client/commit/abfd02abeb8585e44377e9e87e5d20e5d95be002) Thanks [@gronxb](https://github.com/gronxb)! - Fix `networkStatus` with `useSuspenseQuery` not properly updating to ready state when using a `cache-and-network` fetch policy that returns data equal to what is already in the cache. -## 3.9.0-alpha.1 +- [#11483](https://github.com/apollographql/apollo-client/pull/11483) [`6394dda`](https://github.com/apollographql/apollo-client/commit/6394dda47fa83d9ddd922e0d05e62bd872e4ea8e) Thanks [@pipopotamasu](https://github.com/pipopotamasu)! - Fix cache override warning output -### Minor Changes +## 3.8.9 + +### Patch Changes -- [#11178](https://github.com/apollographql/apollo-client/pull/11178) [`4d64a6fa2`](https://github.com/apollographql/apollo-client/commit/4d64a6fa2ad5abe6f7f172c164f5e1fc2cb89829) Thanks [@sebakerckhof](https://github.com/sebakerckhof)! - Support re-using of mocks in the MockedProvider +- [#11472](https://github.com/apollographql/apollo-client/pull/11472) [`afc844d`](https://github.com/apollographql/apollo-client/commit/afc844dd8d6f9f7a3e2003f9a5b541291dfe3fb4) Thanks [@alessbell](https://github.com/alessbell)! - Fix delay: Infinity when set on a MockResponse passed to Mocked Provider so it indefinitely enters loading state. -## 3.9.0-alpha.0 +- [#11464](https://github.com/apollographql/apollo-client/pull/11464) [`aac12b2`](https://github.com/apollographql/apollo-client/commit/aac12b221a6cb776d4941b6c8aadf04f0f0acd27) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Prevent `useFragment` from excessively unsubscribing and resubscribing the fragment with the cache on every render. -### Minor Changes +- [#11449](https://github.com/apollographql/apollo-client/pull/11449) [`f40cda4`](https://github.com/apollographql/apollo-client/commit/f40cda45841e93b056c781c19651b54464f7346a) Thanks [@phryneas](https://github.com/phryneas)! - Removes refences to the typescript "dom" lib. -- [#11202](https://github.com/apollographql/apollo-client/pull/11202) [`7c2bc08b2`](https://github.com/apollographql/apollo-client/commit/7c2bc08b2ab46b9aa181d187a27aec2ad7129599) Thanks [@benjamn](https://github.com/benjamn)! - Prevent `QueryInfo#markResult` mutation of `result.data` and return cache data consistently whether complete or incomplete. +- [#11470](https://github.com/apollographql/apollo-client/pull/11470) [`e293bc9`](https://github.com/apollographql/apollo-client/commit/e293bc90d6f7937a6fc7c169f7b16eeb39d5fd49) Thanks [@phryneas](https://github.com/phryneas)! - Remove an unnecessary check from parseAndCheckHttpResponse. -- [#6701](https://github.com/apollographql/apollo-client/pull/6701) [`8d2b4e107`](https://github.com/apollographql/apollo-client/commit/8d2b4e107d7c21563894ced3a65d631183b58fd9) Thanks [@prowe](https://github.com/prowe)! - Ability to dynamically match mocks +## 3.8.8 - Adds support for a new property `MockedResponse.variableMatcher`: a predicate function that accepts a `variables` param. If `true`, the `variables` will be passed into the `ResultFunction` to help dynamically build a response. +### Patch Changes + +- [#11200](https://github.com/apollographql/apollo-client/pull/11200) [`ae5091a21`](https://github.com/apollographql/apollo-client/commit/ae5091a21f0feff1486503071ea8dc002cf1be41) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Enable `strict` in tsconfig for the entire project. + +- [#11332](https://github.com/apollographql/apollo-client/pull/11332) [`291aea56b`](https://github.com/apollographql/apollo-client/commit/291aea56bfaed3987a98be7fe4e6160114b62d2d) Thanks [@asvishnyakov](https://github.com/asvishnyakov)! - Add missed reexports of MutationFetchPolicy and RefetchWritePolicy to @apollo/client/core + +- [#10931](https://github.com/apollographql/apollo-client/pull/10931) [`e5acf910e`](https://github.com/apollographql/apollo-client/commit/e5acf910e39752b453540b6751046d1c19b66350) Thanks [@phryneas](https://github.com/phryneas)! - `useMutation`: also reset internal state on reset ## 3.8.7 diff --git a/package-lock.json b/package-lock.json index e77230ea76b..3e36f50e536 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@apollo/client", - "version": "3.8.10", + "version": "3.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@apollo/client", - "version": "3.8.10", + "version": "3.9.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 458bd6d5b28..ea7d8df5a5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apollo/client", - "version": "3.8.10", + "version": "3.9.0", "description": "A fully-featured caching GraphQL client.", "private": true, "keywords": [