@apollo/client 3.9.0-rc.1 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +152 -178
- package/README.md +4 -0
- package/apollo-client.cjs +1 -1
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/core/types/DataProxy.d.ts +8 -16
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/inmemory/types.d.ts +0 -1
- package/cache/inmemory/types.js.map +1 -1
- package/core/ApolloClient.d.ts +6 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +22 -0
- package/core/ObservableQuery.js +22 -0
- package/core/ObservableQuery.js.map +1 -1
- package/core/core.cjs +1 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +1 -1
- package/core/types.d.ts +5 -2
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +258 -128
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +1 -1
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +1 -1
- package/package.json +12 -12
- package/react/components/types.d.ts +3 -0
- package/react/components/types.js.map +1 -1
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/useApolloClient.d.ts +15 -0
- package/react/hooks/useApolloClient.js +15 -0
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +35 -0
- package/react/hooks/useLazyQuery.js +35 -0
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +69 -2
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +47 -0
- package/react/hooks/useMutation.js +47 -0
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +34 -0
- package/react/hooks/useQuery.js +34 -0
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +5 -4
- package/react/hooks/useQueryRefHandlers.js +1 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +17 -0
- package/react/hooks/useReactiveVar.js +17 -0
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +85 -0
- package/react/hooks/useSubscription.js +85 -0
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +39 -0
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +84 -52
- package/react/query-preloader/createQueryPreloader.js +5 -2
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/react.cjs.map +1 -1
- package/react/types/types.d.ts +552 -57
- package/react/types/types.documentation.d.ts +559 -0
- package/react/types/types.documentation.js +2 -0
- package/react/types/types.documentation.js.map +1 -0
- package/react/types/types.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/graphql/DocumentTransform.d.ts +12 -0
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/version.js +1 -1
- package/.changeset/beige-geese-wink.md +0 -5
- package/.changeset/breezy-spiders-tap.md +0 -38
- package/.changeset/chatty-comics-yawn.md +0 -8
- package/.changeset/clean-items-smash.md +0 -5
- package/.changeset/cold-llamas-turn.md +0 -8
- package/.changeset/curvy-seas-hope.md +0 -13
- package/.changeset/dirty-kids-crash.md +0 -5
- package/.changeset/dirty-tigers-matter.md +0 -13
- package/.changeset/forty-cups-shop.md +0 -5
- package/.changeset/friendly-clouds-laugh.md +0 -7
- package/.changeset/hot-ducks-burn.md +0 -5
- package/.changeset/late-rabbits-protect.md +0 -7
- package/.changeset/mighty-coats-check.md +0 -47
- package/.changeset/pink-apricots-yawn.md +0 -5
- package/.changeset/polite-avocados-warn.md +0 -5
- package/.changeset/pre.json +0 -45
- package/.changeset/quick-hats-marry.md +0 -5
- package/.changeset/rare-snakes-melt.md +0 -24
- package/.changeset/shaggy-ears-scream.md +0 -5
- package/.changeset/shaggy-sheep-pull.md +0 -5
- package/.changeset/six-rocks-arrive.md +0 -5
- package/.changeset/sixty-boxes-rest.md +0 -8
- package/.changeset/smooth-plums-shout.md +0 -5
- package/.changeset/sour-sheep-walk.md +0 -7
- package/.changeset/spicy-drinks-camp.md +0 -5
- package/.changeset/strong-terms-perform.md +0 -46
- package/.changeset/swift-zoos-collect.md +0 -19
- package/.changeset/thick-mice-collect.md +0 -5
- package/.changeset/thick-tips-cry.md +0 -9
- package/.changeset/thirty-ties-arrive.md +0 -26
- package/.changeset/tough-timers-begin.md +0 -8
- package/.changeset/unlucky-rats-decide.md +0 -5
- package/.changeset/violet-lions-draw.md +0 -5
- package/.changeset/wet-forks-rhyme.md +0 -5
- package/.changeset/wild-dolphins-jog.md +0 -5
- package/.changeset/wise-news-grab.md +0 -7
- package/.changeset/yellow-flies-repeat.md +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,73 +1,95 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
-
## 3.9.0
|
|
3
|
+
## 3.9.0
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Minor Changes
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
#### Memory optimizations
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- [#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
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
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.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
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.
|
|
14
14
|
|
|
15
|
-
- [#
|
|
15
|
+
- [#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`.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
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.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
- [#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.
|
|
20
20
|
|
|
21
|
-
- [#
|
|
21
|
+
- [#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.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
- [#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
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
- use LRU `WeakCache` instead of `Map` to keep a limited number of parsed results
|
|
26
|
+
- cache is initiated lazily, only when needed
|
|
27
|
+
- expose `parse.resetCache()` method
|
|
26
28
|
|
|
27
|
-
- [#
|
|
29
|
+
- [#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`
|
|
28
30
|
|
|
29
|
-
- [#
|
|
31
|
+
- [#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.
|
|
30
32
|
|
|
31
|
-
- [#
|
|
33
|
+
- [#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`
|
|
32
34
|
|
|
33
|
-
- [#
|
|
35
|
+
- [#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`
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
- [#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`
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
- [#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
|
|
38
40
|
|
|
39
|
-
-
|
|
41
|
+
- use LRU `WeakCache` instead of `WeakMap` to keep a limited number of hash results
|
|
42
|
+
- hash cache is initiated lazily, only when needed
|
|
43
|
+
- expose `persistedLink.resetHashCache()` method
|
|
44
|
+
- reset hash cache if the upstream server reports it doesn't accept persisted queries
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
in case the operation would get an additional subscriber at a later point in time.
|
|
43
|
-
In practice, this could lead to a memory leak (#11393) and did not serve any
|
|
44
|
-
further purpose, as the resulting observable would only be subscribed to by
|
|
45
|
-
Apollo Client itself, and only once - it would be wrapped in a `Concast` before
|
|
46
|
-
being exposed to the user, and that `Concast` would handle subscribers on its
|
|
47
|
-
own.
|
|
46
|
+
- [#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
|
|
48
47
|
|
|
49
|
-
- [#
|
|
48
|
+
- [#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)
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
- [#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
|
|
52
51
|
|
|
53
|
-
- [#
|
|
52
|
+
- [#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`
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
#### Suspense-enabled data fetching on user interaction with `useLoadableQuery`
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
- [#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`.
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
```tsx
|
|
59
|
+
function App() {
|
|
60
|
+
const [loadQuery, queryRef, { refetch, fetchMore, reset }] =
|
|
61
|
+
useLoadableQuery(query, options);
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<button onClick={() => loadQuery(variables)}>Load query</button>
|
|
66
|
+
<Suspense fallback={<SuspenseFallback />}>
|
|
67
|
+
{queryRef && <Child queryRef={queryRef} />}
|
|
68
|
+
</Suspense>
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
function Child({ queryRef }) {
|
|
74
|
+
const { data } = useReadQuery(queryRef);
|
|
65
75
|
|
|
66
|
-
|
|
76
|
+
// ...
|
|
77
|
+
}
|
|
78
|
+
```
|
|
67
79
|
|
|
68
|
-
|
|
80
|
+
#### Begin preloading outside of React with `createQueryPreloader`
|
|
69
81
|
|
|
70
|
-
|
|
82
|
+
- [#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.
|
|
83
|
+
|
|
84
|
+
#### Testing utility improvements
|
|
85
|
+
|
|
86
|
+
- [#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
|
|
87
|
+
|
|
88
|
+
- [#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
|
|
89
|
+
|
|
90
|
+
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.
|
|
91
|
+
|
|
92
|
+
#### New `useQueryRefHandlers` hook
|
|
71
93
|
|
|
72
94
|
- [#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.
|
|
73
95
|
|
|
@@ -79,6 +101,8 @@
|
|
|
79
101
|
}
|
|
80
102
|
```
|
|
81
103
|
|
|
104
|
+
#### Bail out of `optimisticResponse` updates with the `IGNORE` sentinel object
|
|
105
|
+
|
|
82
106
|
- [#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.
|
|
83
107
|
|
|
84
108
|
Consider this example:
|
|
@@ -123,8 +147,6 @@
|
|
|
123
147
|
|
|
124
148
|
The `IGNORE` sentinel can be destructured from the second parameter in the callback function signature passed to `optimisticResponse`.
|
|
125
149
|
|
|
126
|
-
- [#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.
|
|
127
|
-
|
|
128
150
|
```tsx
|
|
129
151
|
const preloadQuery = createQueryPreloader(client);
|
|
130
152
|
const queryRef = preloadQuery(QUERY, { variables, ...otherOptions });
|
|
@@ -144,130 +166,11 @@
|
|
|
144
166
|
}
|
|
145
167
|
```
|
|
146
168
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
```ts
|
|
150
|
-
useQuery(QUERY, {
|
|
151
|
-
pollInterval: 1000,
|
|
152
|
-
skipPollAttempt: () => document.hidden, // or !document.hasFocus()
|
|
153
|
-
});
|
|
154
|
-
// or define it globally
|
|
155
|
-
new ApolloClient({
|
|
156
|
-
defaultOptions: {
|
|
157
|
-
watchQuery: {
|
|
158
|
-
skipPollAttempt: () => document.hidden, // or !document.hasFocus()
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
- [#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`.
|
|
165
|
-
|
|
166
|
-
Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option anymore.
|
|
167
|
-
A future version of Apollo Client will contain a similar feature without the risk of memory leaks.
|
|
168
|
-
|
|
169
|
-
### Patch Changes
|
|
170
|
-
|
|
171
|
-
- [#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
|
|
172
|
-
|
|
173
|
-
- use LRU `WeakCache` instead of `WeakMap` to keep a limited number of hash results
|
|
174
|
-
- hash cache is initiated lazily, only when needed
|
|
175
|
-
- expose `persistedLink.resetHashCache()` method
|
|
176
|
-
- reset hash cache if the upstream server reports it doesn't accept persisted queries
|
|
177
|
-
|
|
178
|
-
- [#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
|
|
179
|
-
|
|
180
|
-
- [#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
|
|
181
|
-
|
|
182
|
-
## 3.9.0-alpha.5
|
|
183
|
-
|
|
184
|
-
### Minor Changes
|
|
185
|
-
|
|
186
|
-
- [#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.
|
|
169
|
+
#### Network adapters for multipart subscriptions usage with Relay and urql
|
|
187
170
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
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.
|
|
171
|
+
- [#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
|
|
191
172
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
```tsx
|
|
195
|
-
function App() {
|
|
196
|
-
const [loadQuery, queryRef, { refetch, fetchMore, reset }] =
|
|
197
|
-
useLoadableQuery(query, options);
|
|
198
|
-
|
|
199
|
-
return (
|
|
200
|
-
<>
|
|
201
|
-
<button onClick={() => loadQuery(variables)}>Load query</button>
|
|
202
|
-
<Suspense fallback={<SuspenseFallback />}>
|
|
203
|
-
{queryRef && <Child queryRef={queryRef} />}
|
|
204
|
-
</Suspense>
|
|
205
|
-
</>
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function Child({ queryRef }) {
|
|
210
|
-
const { data } = useReadQuery(queryRef);
|
|
211
|
-
|
|
212
|
-
// ...
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Patch Changes
|
|
217
|
-
|
|
218
|
-
- [#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.
|
|
219
|
-
|
|
220
|
-
- [#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
|
|
221
|
-
|
|
222
|
-
- use LRU `WeakCache` instead of `Map` to keep a limited number of parsed results
|
|
223
|
-
- cache is initiated lazily, only when needed
|
|
224
|
-
- expose `parse.resetCache()` method
|
|
225
|
-
|
|
226
|
-
- [#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`
|
|
227
|
-
|
|
228
|
-
- [#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.
|
|
229
|
-
|
|
230
|
-
- [#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`
|
|
231
|
-
|
|
232
|
-
- [#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`
|
|
233
|
-
|
|
234
|
-
- [#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
|
|
235
|
-
|
|
236
|
-
- [#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`
|
|
237
|
-
|
|
238
|
-
- [#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`.
|
|
239
|
-
|
|
240
|
-
- [#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)
|
|
241
|
-
|
|
242
|
-
## 3.8.8
|
|
243
|
-
|
|
244
|
-
### Patch Changes
|
|
245
|
-
|
|
246
|
-
- [#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.
|
|
247
|
-
|
|
248
|
-
- [#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
|
|
249
|
-
|
|
250
|
-
- [#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
|
|
251
|
-
|
|
252
|
-
## 3.9.0-alpha.4
|
|
253
|
-
|
|
254
|
-
### Minor Changes
|
|
255
|
-
|
|
256
|
-
- [#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
|
|
257
|
-
the Next.js "edge" runtime we now use an external package to wrap `react` imports
|
|
258
|
-
instead of importing React directly.
|
|
259
|
-
|
|
260
|
-
### Patch Changes
|
|
261
|
-
|
|
262
|
-
- [#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`
|
|
263
|
-
|
|
264
|
-
## 3.9.0-alpha.3
|
|
265
|
-
|
|
266
|
-
### Minor Changes
|
|
267
|
-
|
|
268
|
-
- [#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
|
|
269
|
-
|
|
270
|
-
### Relay
|
|
173
|
+
##### Relay
|
|
271
174
|
|
|
272
175
|
```tsx
|
|
273
176
|
import { createFetchMultipartSubscription } from "@apollo/client/utilities/subscriptions/relay";
|
|
@@ -285,7 +188,7 @@
|
|
|
285
188
|
});
|
|
286
189
|
```
|
|
287
190
|
|
|
288
|
-
|
|
191
|
+
##### Urql
|
|
289
192
|
|
|
290
193
|
```tsx
|
|
291
194
|
import { createFetchMultipartSubscription } from "@apollo/client/utilities/subscriptions/urql";
|
|
@@ -306,12 +209,60 @@
|
|
|
306
209
|
});
|
|
307
210
|
```
|
|
308
211
|
|
|
309
|
-
|
|
212
|
+
#### `skipPollAttempt` callback function
|
|
213
|
+
|
|
214
|
+
- [#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.
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
useQuery(QUERY, {
|
|
218
|
+
pollInterval: 1000,
|
|
219
|
+
skipPollAttempt: () => document.hidden, // or !document.hasFocus()
|
|
220
|
+
});
|
|
221
|
+
// or define it globally
|
|
222
|
+
new ApolloClient({
|
|
223
|
+
defaultOptions: {
|
|
224
|
+
watchQuery: {
|
|
225
|
+
skipPollAttempt: () => document.hidden, // or !document.hasFocus()
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### `QueryManager.inFlightLinkObservables` now uses a strong `Trie` as an internal data structure
|
|
310
232
|
|
|
311
|
-
- [#
|
|
233
|
+
- [#11345](https://github.com/apollographql/apollo-client/pull/11345) [`1759066`](https://github.com/apollographql/apollo-client/commit/1759066a8f9a204e49228568aef9446a64890ff3) Thanks [@phryneas](https://github.com/phryneas)!
|
|
312
234
|
|
|
313
|
-
|
|
314
|
-
|
|
235
|
+
##### Warning: requires `@apollo/experimental-nextjs-app-support` update
|
|
236
|
+
|
|
237
|
+
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.
|
|
238
|
+
|
|
239
|
+
<details open>
|
|
240
|
+
<summary><h4>More Minor Changes</h4></summary>
|
|
241
|
+
|
|
242
|
+
- [#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.
|
|
243
|
+
|
|
244
|
+
- [#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.
|
|
245
|
+
|
|
246
|
+
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.
|
|
247
|
+
|
|
248
|
+
- [#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.
|
|
249
|
+
|
|
250
|
+
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.
|
|
251
|
+
|
|
252
|
+
- [#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
|
|
253
|
+
the Next.js "edge" runtime we now use an external package to wrap `react` imports
|
|
254
|
+
instead of importing React directly.
|
|
255
|
+
|
|
256
|
+
- [#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`.
|
|
257
|
+
|
|
258
|
+
</details>
|
|
259
|
+
|
|
260
|
+
<details open>
|
|
261
|
+
<summary><h3>Patch Changes</h3></summary>
|
|
262
|
+
|
|
263
|
+
- [#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.
|
|
264
|
+
|
|
265
|
+
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.
|
|
315
266
|
|
|
316
267
|
```js
|
|
317
268
|
import { ApolloClient, createHttpLink, InMemoryCache } from "@apollo/client";
|
|
@@ -343,29 +294,52 @@
|
|
|
343
294
|
}
|
|
344
295
|
```
|
|
345
296
|
|
|
346
|
-
- [#
|
|
297
|
+
- [#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.
|
|
347
298
|
|
|
348
|
-
|
|
299
|
+
The HOC and render prop APIs have already been deprecated since 2020,
|
|
300
|
+
but we previously didn't have a `@deprecated` tag in the DocBlocks.
|
|
301
|
+
|
|
302
|
+
- [#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
|
|
303
|
+
|
|
304
|
+
- [#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)
|
|
305
|
+
|
|
306
|
+
- [#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
|
|
307
|
+
|
|
308
|
+
- [#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.
|
|
309
|
+
|
|
310
|
+
- [#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`.
|
|
311
|
+
|
|
312
|
+
</details>
|
|
313
|
+
|
|
314
|
+
## 3.8.10
|
|
349
315
|
|
|
350
316
|
### Patch Changes
|
|
351
317
|
|
|
352
|
-
- [#
|
|
318
|
+
- [#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.
|
|
353
319
|
|
|
354
|
-
|
|
320
|
+
- [#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
|
|
355
321
|
|
|
356
|
-
|
|
322
|
+
## 3.8.9
|
|
323
|
+
|
|
324
|
+
### Patch Changes
|
|
357
325
|
|
|
358
|
-
- [#
|
|
326
|
+
- [#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.
|
|
359
327
|
|
|
360
|
-
|
|
328
|
+
- [#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.
|
|
361
329
|
|
|
362
|
-
|
|
330
|
+
- [#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.
|
|
363
331
|
|
|
364
|
-
- [#
|
|
332
|
+
- [#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.
|
|
365
333
|
|
|
366
|
-
|
|
334
|
+
## 3.8.8
|
|
367
335
|
|
|
368
|
-
|
|
336
|
+
### Patch Changes
|
|
337
|
+
|
|
338
|
+
- [#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.
|
|
339
|
+
|
|
340
|
+
- [#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
|
|
341
|
+
|
|
342
|
+
- [#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
|
|
369
343
|
|
|
370
344
|
## 3.8.7
|
|
371
345
|
|
package/README.md
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI components that fetch data via GraphQL.
|
|
13
13
|
|
|
14
|
+
| ☑️ Apollo Client User Survey |
|
|
15
|
+
| :----- |
|
|
16
|
+
| What do you like best about Apollo Client? What needs to be improved? Please tell us by taking a [one-minute survey](https://docs.google.com/forms/d/e/1FAIpQLSczNDXfJne3ZUOXjk9Ursm9JYvhTh1_nFTDfdq3XBAFWCzplQ/viewform?usp=pp_url&entry.1170701325=Apollo+Client&entry.204965213=Readme). Your responses will help us understand Apollo Client usage and allow us to serve you better. |
|
|
17
|
+
|
|
14
18
|
## Documentation
|
|
15
19
|
|
|
16
20
|
All Apollo Client documentation, including React integration articles and helpful recipes, can be found at: <br/>
|
package/apollo-client.cjs
CHANGED
|
@@ -33,7 +33,7 @@ var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
|
33
33
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
34
|
var React__namespace$1 = /*#__PURE__*/_interopNamespace(React$1);
|
|
35
35
|
|
|
36
|
-
var version = "3.9.0
|
|
36
|
+
var version = "3.9.0";
|
|
37
37
|
|
|
38
38
|
function maybe(thunk) {
|
|
39
39
|
try {
|