@apollo/client 4.0.0-rc.9 → 4.0.1

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.
Files changed (209) hide show
  1. package/CHANGELOG.md +2484 -0
  2. package/README.md +6 -2
  3. package/__cjs/cache/inmemory/inMemoryCache.cjs +2 -2
  4. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  5. package/__cjs/cache/inmemory/policies.cjs +18 -12
  6. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  7. package/__cjs/core/ObservableQuery.cjs +3 -2
  8. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  9. package/__cjs/core/ObservableQuery.d.cts +1 -1
  10. package/__cjs/core/QueryManager.cjs +1 -1
  11. package/__cjs/core/QueryManager.cjs.map +1 -1
  12. package/__cjs/core/index.cjs +3 -2
  13. package/__cjs/core/index.cjs.map +1 -1
  14. package/__cjs/core/index.d.cts +5 -3
  15. package/__cjs/core/networkStatus.cjs +0 -16
  16. package/__cjs/core/networkStatus.cjs.map +1 -1
  17. package/__cjs/core/networkStatus.d.cts +0 -10
  18. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  19. package/__cjs/incremental/handlers/defer20220824.d.cts +9 -6
  20. package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
  21. package/__cjs/incremental/handlers/notImplemented.d.cts +11 -0
  22. package/__cjs/invariantErrorCodes.cjs +12 -6
  23. package/__cjs/link/core/ApolloLink.cjs.map +1 -1
  24. package/__cjs/link/core/ApolloLink.d.cts +5 -2
  25. package/__cjs/link/core/types.d.cts +0 -4
  26. package/__cjs/link/index.cjs.map +1 -1
  27. package/__cjs/link/index.d.cts +2 -1
  28. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +2 -2
  29. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  30. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +2 -2
  31. package/__cjs/local-state/LocalState.cjs.map +1 -1
  32. package/__cjs/masking/GraphQLCodegenDataMasking.d.cts +10 -42
  33. package/__cjs/masking/PreserveTypes.cjs +3 -0
  34. package/__cjs/masking/PreserveTypes.cjs.map +1 -0
  35. package/__cjs/masking/PreserveTypes.d.cts +26 -0
  36. package/__cjs/masking/index.cjs.map +1 -1
  37. package/__cjs/masking/index.d.cts +1 -1
  38. package/__cjs/masking/internal/types.d.cts +0 -1
  39. package/__cjs/masking/types.d.cts +6 -23
  40. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  41. package/__cjs/react/hooks/useBackgroundQuery.d.cts +2 -1
  42. package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
  43. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  44. package/__cjs/react/hooks/useLoadableQuery.d.cts +2 -1
  45. package/__cjs/react/hooks/useQuery.d.cts +1 -1
  46. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  47. package/__cjs/react/hooks/useQueryRefHandlers.d.cts +2 -1
  48. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  49. package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
  50. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  51. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
  52. package/__cjs/react/types/deprecated.d.cts +1 -1
  53. package/__cjs/react/types/types.documentation.d.cts +1 -1
  54. package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +1 -1
  55. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  56. package/__cjs/testing/react/MockedProvider.d.cts +5 -0
  57. package/__cjs/utilities/common/stripTypename.cjs +11 -0
  58. package/__cjs/utilities/common/stripTypename.cjs.map +1 -1
  59. package/__cjs/utilities/common/stripTypename.d.cts +11 -0
  60. package/__cjs/utilities/graphql/DocumentTransform.cjs +84 -1
  61. package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
  62. package/__cjs/utilities/graphql/DocumentTransform.d.cts +94 -5
  63. package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs +27 -0
  64. package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs.map +1 -1
  65. package/__cjs/utilities/graphql/isFormattedExecutionResult.d.cts +27 -0
  66. package/__cjs/utilities/graphql/operations.cjs +54 -3
  67. package/__cjs/utilities/graphql/operations.cjs.map +1 -1
  68. package/__cjs/utilities/graphql/operations.d.cts +54 -3
  69. package/__cjs/utilities/graphql/storeUtils.cjs +9 -0
  70. package/__cjs/utilities/graphql/storeUtils.cjs.map +1 -1
  71. package/__cjs/utilities/graphql/storeUtils.d.cts +9 -0
  72. package/__cjs/utilities/graphql/transform.cjs +12 -1
  73. package/__cjs/utilities/graphql/transform.cjs.map +1 -1
  74. package/__cjs/utilities/graphql/transform.d.cts +12 -1
  75. package/__cjs/utilities/index.cjs +5 -1
  76. package/__cjs/utilities/index.cjs.map +1 -1
  77. package/__cjs/utilities/index.d.cts +2 -0
  78. package/__cjs/utilities/internal/canonicalStringify.cjs +30 -7
  79. package/__cjs/utilities/internal/canonicalStringify.cjs.map +1 -1
  80. package/__cjs/utilities/internal/canonicalStringify.d.cts +30 -7
  81. package/__cjs/utilities/internal/getMainDefinition.cjs +36 -8
  82. package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -1
  83. package/__cjs/utilities/internal/getMainDefinition.d.cts +36 -8
  84. package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +1 -1
  85. package/__cjs/utilities/isNetworkRequestInFlight.cjs +12 -0
  86. package/__cjs/utilities/isNetworkRequestInFlight.cjs.map +1 -0
  87. package/__cjs/utilities/isNetworkRequestInFlight.d.cts +7 -0
  88. package/__cjs/utilities/isNetworkRequestSettled.cjs +11 -0
  89. package/__cjs/utilities/isNetworkRequestSettled.cjs.map +1 -0
  90. package/__cjs/utilities/isNetworkRequestSettled.d.cts +7 -0
  91. package/__cjs/v4-migration.cjs +9 -0
  92. package/__cjs/v4-migration.cjs.map +1 -0
  93. package/__cjs/v4-migration.d.cts +826 -0
  94. package/__cjs/version.cjs +1 -1
  95. package/__cjs/version.cjs.map +1 -1
  96. package/cache/inmemory/inMemoryCache.js +2 -2
  97. package/cache/inmemory/inMemoryCache.js.map +1 -1
  98. package/cache/inmemory/policies.js +18 -12
  99. package/cache/inmemory/policies.js.map +1 -1
  100. package/core/ObservableQuery.d.ts +1 -1
  101. package/core/ObservableQuery.js +2 -1
  102. package/core/ObservableQuery.js.map +1 -1
  103. package/core/QueryManager.js +2 -2
  104. package/core/QueryManager.js.map +1 -1
  105. package/core/index.d.ts +5 -3
  106. package/core/index.js +4 -2
  107. package/core/index.js.map +1 -1
  108. package/core/networkStatus.d.ts +0 -10
  109. package/core/networkStatus.js +0 -14
  110. package/core/networkStatus.js.map +1 -1
  111. package/incremental/handlers/defer20220824.d.ts +9 -6
  112. package/incremental/handlers/defer20220824.js.map +1 -1
  113. package/incremental/handlers/notImplemented.d.ts +11 -0
  114. package/incremental/handlers/notImplemented.js.map +1 -1
  115. package/invariantErrorCodes.js +2 -2
  116. package/legacyEntryPoints/v4-migration/index.d.ts +1 -0
  117. package/legacyEntryPoints/v4-migration/index.js +1 -0
  118. package/legacyEntryPoints/v4-migration/v4-migration.cjs +1 -0
  119. package/legacyEntryPoints/v4-migration/v4-migration.d.cts +1 -0
  120. package/link/core/ApolloLink.d.ts +5 -2
  121. package/link/core/ApolloLink.js.map +1 -1
  122. package/link/core/types.d.ts +0 -4
  123. package/link/core/types.js.map +1 -1
  124. package/link/index.d.ts +2 -1
  125. package/link/index.js.map +1 -1
  126. package/link/remove-typename/removeTypenameFromVariables.d.ts +2 -2
  127. package/link/remove-typename/removeTypenameFromVariables.js +2 -2
  128. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  129. package/local-state/LocalState.js.map +1 -1
  130. package/masking/GraphQLCodegenDataMasking.d.ts +10 -42
  131. package/masking/GraphQLCodegenDataMasking.js.map +1 -1
  132. package/masking/PreserveTypes.d.ts +26 -0
  133. package/masking/PreserveTypes.js +2 -0
  134. package/masking/PreserveTypes.js.map +1 -0
  135. package/masking/index.d.ts +1 -1
  136. package/masking/index.js.map +1 -1
  137. package/masking/internal/types.d.ts +0 -1
  138. package/masking/internal/types.js.map +1 -1
  139. package/masking/types.d.ts +6 -23
  140. package/masking/types.js.map +1 -1
  141. package/package.json +8 -2
  142. package/react/hooks/useBackgroundQuery.d.ts +2 -1
  143. package/react/hooks/useBackgroundQuery.js.map +1 -1
  144. package/react/hooks/useLazyQuery.d.ts +1 -1
  145. package/react/hooks/useLoadableQuery.d.ts +2 -1
  146. package/react/hooks/useLoadableQuery.js.map +1 -1
  147. package/react/hooks/useQuery.d.ts +1 -1
  148. package/react/hooks/useQueryRefHandlers.d.ts +2 -1
  149. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  150. package/react/hooks/useReadQuery.d.ts +1 -1
  151. package/react/hooks/useReadQuery.js.map +1 -1
  152. package/react/hooks-compiled/useBackgroundQuery.d.ts +2 -1
  153. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  154. package/react/hooks-compiled/useLazyQuery.d.ts +1 -1
  155. package/react/hooks-compiled/useLoadableQuery.d.ts +2 -1
  156. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  157. package/react/hooks-compiled/useQuery.d.ts +1 -1
  158. package/react/hooks-compiled/useQueryRefHandlers.d.ts +2 -1
  159. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  160. package/react/hooks-compiled/useReadQuery.d.ts +1 -1
  161. package/react/hooks-compiled/useReadQuery.js.map +1 -1
  162. package/react/query-preloader/createQueryPreloader.d.ts +1 -1
  163. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  164. package/react/types/deprecated.d.ts +1 -1
  165. package/react/types/deprecated.js.map +1 -1
  166. package/react/types/types.documentation.d.ts +1 -1
  167. package/react/types/types.documentation.js.map +1 -1
  168. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  169. package/testing/react/MockedProvider.d.ts +5 -0
  170. package/testing/react/MockedProvider.js.map +1 -1
  171. package/utilities/common/stripTypename.d.ts +11 -0
  172. package/utilities/common/stripTypename.js +11 -0
  173. package/utilities/common/stripTypename.js.map +1 -1
  174. package/utilities/graphql/DocumentTransform.d.ts +94 -5
  175. package/utilities/graphql/DocumentTransform.js +84 -1
  176. package/utilities/graphql/DocumentTransform.js.map +1 -1
  177. package/utilities/graphql/isFormattedExecutionResult.d.ts +27 -0
  178. package/utilities/graphql/isFormattedExecutionResult.js +27 -0
  179. package/utilities/graphql/isFormattedExecutionResult.js.map +1 -1
  180. package/utilities/graphql/operations.d.ts +54 -3
  181. package/utilities/graphql/operations.js +54 -3
  182. package/utilities/graphql/operations.js.map +1 -1
  183. package/utilities/graphql/storeUtils.d.ts +9 -0
  184. package/utilities/graphql/storeUtils.js +9 -0
  185. package/utilities/graphql/storeUtils.js.map +1 -1
  186. package/utilities/graphql/transform.d.ts +12 -1
  187. package/utilities/graphql/transform.js +12 -1
  188. package/utilities/graphql/transform.js.map +1 -1
  189. package/utilities/index.d.ts +2 -0
  190. package/utilities/index.js +2 -0
  191. package/utilities/index.js.map +1 -1
  192. package/utilities/internal/canonicalStringify.d.ts +30 -7
  193. package/utilities/internal/canonicalStringify.js +30 -7
  194. package/utilities/internal/canonicalStringify.js.map +1 -1
  195. package/utilities/internal/getMainDefinition.d.ts +37 -9
  196. package/utilities/internal/getMainDefinition.js +36 -8
  197. package/utilities/internal/getMainDefinition.js.map +1 -1
  198. package/utilities/internal/types/DocumentationTypes.d.ts +1 -1
  199. package/utilities/isNetworkRequestInFlight.d.ts +7 -0
  200. package/utilities/isNetworkRequestInFlight.js +9 -0
  201. package/utilities/isNetworkRequestInFlight.js.map +1 -0
  202. package/utilities/isNetworkRequestSettled.d.ts +7 -0
  203. package/utilities/isNetworkRequestSettled.js +8 -0
  204. package/utilities/isNetworkRequestSettled.js.map +1 -0
  205. package/v4-migration.d.ts +826 -0
  206. package/v4-migration.js +8 -0
  207. package/v4-migration.js.map +1 -0
  208. package/version.js +1 -1
  209. package/version.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,2419 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#12876](https://github.com/apollographql/apollo-client/pull/12876) [`b00f231`](https://github.com/apollographql/apollo-client/commit/b00f231e5f10a23178cf7a2c69a4e13cd959ab45) Thanks [@phryneas](https://github.com/phryneas)! - Fix CJS build output for `invariantErrorCodes`
8
+
9
+ - [#12866](https://github.com/apollographql/apollo-client/pull/12866) [`0d1614a`](https://github.com/apollographql/apollo-client/commit/0d1614a9dfca2b1bcf4ea40095cc9018d6314532) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Export `isNetworkStatusInFlight` from `@apollo/client/utilities`. Add `isNetworkStatusSettled` to `@apollo/client/utilities` and re-export it from `@apollo/client` with a deprecation.
10
+
11
+ ## 4.0.0
12
+
13
+ # Apollo Client 4.0 Release Notes
14
+
15
+ Apollo Client 4.0 delivers a more modern, efficient, and type-safe GraphQL client experience through various architectural improvements and API refinements. This release focuses on developer experience, bundle size optimization, and framework flexibility.
16
+
17
+ ## Key Improvements
18
+
19
+ ### 🎯 Framework-Agnostic Core
20
+
21
+ Apollo Client 4.0 separates React functionality from the core library, making `@apollo/client` truly framework-agnostic. React exports now live in `@apollo/client/react`, allowing developers to use Apollo Client with any JavaScript framework without React dependencies.
22
+
23
+ ### 📦 Smaller Bundle Sizes
24
+
25
+ - **Opt-in Local State Management**: The `@client` directive functionality is now opt-in via the `LocalState` class, reducing bundle size when not using local state
26
+ - **Modern Build Target**: Transpiled to target `since 2023, node >= 20, not dead`, leveraging modern JavaScript features for better performance
27
+ - **Improved Tree-Shaking**: Proper `exports` field in package.json enables better dead code elimination
28
+
29
+ ### 💥 Unified Error Handling
30
+
31
+ Apollo Client 4.0 completely reimagines error handling for better clarity and debugging:
32
+
33
+ - `ApolloError` removed in favor of specific error classes
34
+ - Unification of errors to a single `error` property
35
+ - Network errors now respect `errorPolicy` settings
36
+ - External errors passed through without wrapping
37
+ - New, more granular error classes with static `.is()` methods for robust type narrowing
38
+
39
+ ### 🔧 Enhanced TypeScript Support
40
+
41
+ - **Namespaced Types**: Types are now colocated with their APIs (e.g., `useQuery.Options` instead of `QueryHookOptions`)
42
+ - **Precise Return Types**: Return types accurately reflect the options passed (e.g., `returnPartialData` makes `data` type `DeepPartial<TData>`)
43
+ - **Stricter Type Safety**: Required variables are now enforced more consistently throughout the client
44
+ - **New `dataState` Property**: Enables accurate type narrowing of query results
45
+ - **Module Augmentation**: Custom context types via declaration merging instead of fragile generics
46
+ - **Customizable Type Implementations**: Select types can now be customized to provide your own type implementation to seamlessly integrate with external tools such as GraphQL Codegen or `gql.tada`
47
+
48
+ ### ⚡ Modern Observable Implementation
49
+
50
+ Apollo Client 4.0 migrates from `zen-observable` to **RxJS**, providing the industry-standard Observable implementation backed by a rich ecosystem of utilities.
51
+
52
+ ## Major Features
53
+
54
+ ### Unified Error Handling
55
+
56
+ Apollo Client 4.0 completely reimagines error handling for better clarity and debugging:
57
+
58
+ **Key Changes:**
59
+
60
+ - `ApolloError` removed in favor of specific error classes
61
+ - Network errors now respect `errorPolicy` settings
62
+ - External errors passed through without wrapping
63
+ - New error classes with static `.is()` methods for type checking
64
+
65
+ **Error Classes:**
66
+
67
+ - `CombinedGraphQLErrors` - GraphQL errors from the server
68
+ - `ServerError` - Non-GraphQL server errors
69
+ - `ServerParseError` - Server response parsing errors
70
+ - `UnconventionalError` - Wrapper for non-error thrown values
71
+ - `LinkError` - Errors from the link chain (via `.is()` check)
72
+
73
+ **Migration Example:**
74
+
75
+ ```typescript
76
+ // Apollo Client 3
77
+ if (error instanceof ApolloError) {
78
+ console.log(error.graphQLErrors);
79
+ console.log(error.networkError);
80
+ }
81
+
82
+ // Apollo Client 4
83
+ import { CombinedGraphQLErrors } from "@apollo/client";
84
+
85
+ if (CombinedGraphQLErrors.is(error)) {
86
+ console.log(error.errors); // GraphQL errors
87
+ } else if (error) {
88
+ console.log(error.message); // Other errors
89
+ }
90
+ ```
91
+
92
+ ### The `dataState` Property
93
+
94
+ A new property that clearly indicates the completeness of query results:
95
+
96
+ **Values:**
97
+
98
+ - `empty` - No data available (`data` is `undefined`)
99
+ - `partial` - Incomplete data from cache when `returnPartialData` is `true`
100
+ - `streaming` - Incomplete data from a deferred query still streaming
101
+ - `complete` - Fully satisfied query result
102
+
103
+ **Benefits:**
104
+
105
+ - Accurate TypeScript type narrowing
106
+ - Clear loading state distinction
107
+ - Better handling of partial results
108
+
109
+ ```typescript
110
+ const { data, dataState } = useQuery(MY_QUERY);
111
+
112
+ if (dataState === "complete") {
113
+ // TypeScript knows data is fully populated
114
+ console.log(data.allFields);
115
+ } else if (dataState === "partial") {
116
+ // TypeScript knows data might be missing fields
117
+ console.log(data?.someField);
118
+ }
119
+ ```
120
+
121
+ ### Pluggable Incremental Delivery (`@defer` Support)
122
+
123
+ Apollo Client 4.0 makes incremental delivery configurable and future-proof:
124
+
125
+ ```typescript
126
+ import { Defer20220824Handler } from "@apollo/client/incremental";
127
+
128
+ const client = new ApolloClient({
129
+ // ...
130
+ incrementalHandler: new Defer20220824Handler(),
131
+ });
132
+ ```
133
+
134
+ **Available Handlers:**
135
+
136
+ - `NotImplementedHandler` - Default, throws if `@defer` is used
137
+ - `Defer20220824Handler` - Apollo Router format support (also aliased as `GraphQL17Alpha2Handler`)
138
+
139
+ ### Local State Management Improvements
140
+
141
+ Local state is now opt-in via the `LocalState` class:
142
+
143
+ ```typescript
144
+ import { LocalState } from "@apollo/client/local-state";
145
+
146
+ const client = new ApolloClient({
147
+ cache,
148
+ localState: new LocalState({
149
+ resolvers: {
150
+ Query: {
151
+ myField: () => "Hello World",
152
+ },
153
+ },
154
+ }),
155
+ });
156
+ ```
157
+
158
+ **Resolver Context Changes:**
159
+
160
+ ```typescript
161
+ // Apollo Client 3
162
+ const resolver = (parent, args, context, info) => {
163
+ const { cache } = context;
164
+ };
165
+
166
+ // Apollo Client 4
167
+ const resolver = (parent, args, context, info) => {
168
+ const { client, requestContext, phase } = context;
169
+ const cache = client.cache;
170
+ };
171
+ ```
172
+
173
+ ## React-Specific Improvements
174
+
175
+ ### More Predictable Hooks
176
+
177
+ **`useLazyQuery` Overhaul:**
178
+
179
+ - No longer accepts `variables` or `context` options (pass to `execute` instead)
180
+ - `execute` function only accepts `variables` and `context`
181
+ - Cannot be called during render or SSR
182
+ - Automatic cancellation of in-flight queries when new ones start
183
+
184
+ **`useMutation` Changes:**
185
+
186
+ - Removed `ignoreResults` option - use `client.mutate` directly for fire-and-forget mutations
187
+
188
+ **`useQuery` Changes:**
189
+
190
+ - `notifyOnNetworkStatusChange` now defaults to `true`
191
+ - Removed deprecated `onCompleted` and `onError` callbacks
192
+
193
+ ### New SSR API
194
+
195
+ The new `prerenderStatic` API replaces deprecated SSR functions:
196
+
197
+ ```typescript
198
+ import { prerenderStatic } from "@apollo/client/react/ssr";
199
+
200
+ // Works with React 19's prerender APIs
201
+ const html = await prerenderStatic(<App />, {
202
+ client,
203
+ });
204
+ ```
205
+
206
+ ### React Compiler Support
207
+
208
+ Pre-compiled React hooks optimized by the React Compiler:
209
+
210
+ ```typescript
211
+ // Use compiled hooks for potential performance improvements
212
+ import { useQuery } from "@apollo/client/react/compiled";
213
+ ```
214
+
215
+ The compiled hooks are built with React Compiler v19.1.0-rc.2 and include a runtime polyfill for compatibility with React 17+.
216
+
217
+ ## Link System Evolution
218
+
219
+ ### All Links Now Classes
220
+
221
+ Migration from creator functions to classes:
222
+
223
+ ```typescript
224
+ // Apollo Client 3
225
+ import { createHttpLink, setContext } from "@apollo/client";
226
+ const httpLink = createHttpLink({ uri: "/graphql" });
227
+ const authLink = setContext((operation, prevContext) => {
228
+ /*...*/
229
+ });
230
+
231
+ // Apollo Client 4
232
+ import { HttpLink, SetContextLink } from "@apollo/client";
233
+ const httpLink = new HttpLink({ uri: "/graphql" });
234
+ const authLink = new SetContextLink((prevContext, operation) => {
235
+ /*...*/
236
+ });
237
+ ```
238
+
239
+ ### ErrorLink Changes
240
+
241
+ ```typescript
242
+ // Apollo Client 3
243
+ onError(({ graphQLErrors, networkError }) => {
244
+ // Handle errors separately
245
+ });
246
+
247
+ // Apollo Client 4
248
+ new ErrorLink(({ error }) => {
249
+ if (CombinedGraphQLErrors.is(error)) {
250
+ // Handle GraphQL errors
251
+ } else if (error) {
252
+ // Handle other errors
253
+ }
254
+ });
255
+ ```
256
+
257
+ ## Migration Tools
258
+
259
+ ### Automated Codemod
260
+
261
+ Apollo Client 4.0 provides a comprehensive codemod to automate migration:
262
+
263
+ ```bash
264
+ # Basic usage
265
+ npx @apollo/client-codemod-migrate-3-to-4 src
266
+
267
+ # TypeScript projects (run separately)
268
+ npx @apollo/client-codemod-migrate-3-to-4 --parser ts --extensions ts src
269
+ npx @apollo/client-codemod-migrate-3-to-4 --parser tsx --extensions tsx src
270
+ ```
271
+
272
+ The codemod handles:
273
+
274
+ 1. **Import updates** - Moves React imports to `@apollo/client/react`
275
+ 2. **Type migrations** - Updates types to new namespaced locations
276
+ 3. **Link updates** - Converts creator functions to classes
277
+ 4. **Removed exports** - Moves to `@apollo/client/v4-migration` with migration instructions
278
+
279
+ ## Breaking Changes Summary
280
+
281
+ ### Installation
282
+
283
+ ```bash
284
+ # RxJS is now a peer dependency
285
+ npm install @apollo/client graphql rxjs
286
+ ```
287
+
288
+ ### ApolloClient Constructor
289
+
290
+ - `link` option is now required (no more implicit `HttpLink` creation)
291
+ - `uri`, `headers`, `credentials` removed - use `HttpLink` directly
292
+ - `name` and `version` moved to `clientAwareness` option
293
+ - `resolvers` moved to `LocalState` constructor
294
+ - `connectToDevTools` replaced with `devtools.enabled`
295
+ - `disableNetworkFetches` renamed to `prioritizeCacheValues`
296
+
297
+ ### Type System
298
+
299
+ - Removed `TContext` and `TCacheShape` generics
300
+ - Types moved to namespaces (see migration guide for full list)
301
+ - Custom context via module augmentation
302
+
303
+ ### Observable Changes
304
+
305
+ - Requires calling `.pipe()` for transformations
306
+ - Use RxJS operators instead of method chaining
307
+
308
+ ### Testing
309
+
310
+ - `MockedProvider` now has realistic delays by default (20-50ms)
311
+ - `createMockClient` removed - use `MockLink` directly
312
+
313
+ ## Performance & Build Improvements
314
+
315
+ - **Modern JavaScript**: No downlevel transpilation for modern features
316
+ - **No Polyfills**: Cleaner bundles, bring your own if needed
317
+ - **Development Mode**: Controlled via export conditions, not global `__DEV__`
318
+ - **ESM Support**: Proper `exports` field for better module resolution
319
+ - **Source Maps**: Fixed and improved for better debugging
320
+
321
+ ## Deprecations & Removals
322
+
323
+ ### Removed Packages/Exports
324
+
325
+ - React render prop components (`@apollo/client/react/components`)
326
+ - Higher-order components (`@apollo/client/react/hoc`)
327
+ - `@apollo/client/react/parser`
328
+ - `@apollo/client/utilities/globals`
329
+
330
+ ## Upgrade Path
331
+
332
+ 1. **Update to Apollo Client 3.14** first for deprecation warnings
333
+ 2. **Install peer dependencies**: `npm install rxjs`
334
+ 3. **Run the codemod** to automate import and type updates
335
+ 4. **Update ApolloClient initialization** (explicit `HttpLink`, `LocalState` if needed)
336
+ 5. **Review error handling** - update to use new error classes
337
+ 6. **Test thoroughly** - especially SSR, error handling, and local state
338
+
339
+ ## Resources
340
+
341
+ - [Migration Guide](https://www.apollographql.com/docs/react/migrating/apollo-client-4-migration)
342
+ - [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md)
343
+
344
+ ## Acknowledgments
345
+
346
+ Apollo Client 4.0 represents years of community feedback and contributions. Thank you to all our contributors, early adopters, and the entire GraphQL community for making this release possible.
347
+
348
+ <details>
349
+
350
+ <summary>
351
+
352
+ ### Major Changes
353
+
354
+ </summary>
355
+
356
+ - [#12644](https://github.com/apollographql/apollo-client/pull/12644) [`fe2f005`](https://github.com/apollographql/apollo-client/commit/fe2f005c34913ae082b96a807dc240e2785d50bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Replace the `result` property on `ServerError` with `bodyText`. `bodyText` is set to the raw string body. `HttpLink` and `BatchHttpLink` no longer try and parse the response body as JSON when a `ServerError` is thrown.
357
+
358
+ - [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - The `includeExtensions` option of `HttpLink` and `BatchHttpLink` now defaults
359
+ to `true`.
360
+
361
+ If `includeExtensions` is `true`, but `extensions` is not set or empty, extensions
362
+ will not be included in outgoing requests.
363
+
364
+ - [#12686](https://github.com/apollographql/apollo-client/pull/12686) [`dc4b1d0`](https://github.com/apollographql/apollo-client/commit/dc4b1d0d2479a37067113b7bd161a550fb8e4df6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - A `@defer` query that has not yet finished streaming is now considered loading and thus the `loading` flag will be `true` until the response has completed. A new `NetworkStatus.streaming` value has been introduced and will be set as the `networkStatus` while the response is streaming.
365
+
366
+ - [#12539](https://github.com/apollographql/apollo-client/pull/12539) [`dd0d6d6`](https://github.com/apollographql/apollo-client/commit/dd0d6d6d96d8b810e30dc2fdee2ac8a2477d0017) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `onError` link now uses a single `error` property to report the error that caused the link callback to be called. This will be an instance of `CombinedGraphQLErrors` in the event GraphQL errors were emitted from the terminating link, `CombinedProtocolErrors` if the terminating link emitted protocol errors, or the unwrapped error type if any other non-GraphQL error was thrown or emitted.
367
+
368
+ ```diff
369
+ - const errorLink = onError(({ graphQLErrors, networkError, protocolErrors }) => {
370
+ - graphQLErrors.forEach(error => console.log(error.message));
371
+ + const errorLink = onError(({ error }) => {
372
+ + if (error.name === 'CombinedGraphQLErrors') {
373
+ + error.errors.forEach(rawError => console.log(rawError.message));
374
+ + }
375
+ });
376
+ ```
377
+
378
+ - [#12586](https://github.com/apollographql/apollo-client/pull/12586) [`605db8e`](https://github.com/apollographql/apollo-client/commit/605db8e94fe2ce74c0a395f38f6873d40f431365) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `typeDefs` option from `ApolloClient`.
379
+
380
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `asyncMap` utility function. Instead use one of the RxJS operators that creates Observables from promises, such as `from`.
381
+
382
+ - [#12398](https://github.com/apollographql/apollo-client/pull/12398) [`8cf5077`](https://github.com/apollographql/apollo-client/commit/8cf5077bed1ab46fdd32c5e253071506c0076064) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `isApolloError` utility function to check if the error object is an `ApolloError` instance. Use `instanceof` to check for more specific error types that replace `ApolloError`.
383
+
384
+ - [#12379](https://github.com/apollographql/apollo-client/pull/12379) [`ef892b4`](https://github.com/apollographql/apollo-client/commit/ef892b4dc505b02049525f9aba32c51f1c00c922) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `addTypename` option from `InMemoryCache` and `MockedProvider`. `__typename` is now always added to the outgoing query document when using `InMemoryCache` and cannot be disabled.
385
+
386
+ If you are using `<MockedProvider />` with `addTypename={false}`, ensure that your mocked responses include a `__typename` field. This will ensure cache normalization kicks in and behaves more like production.
387
+
388
+ - [#12396](https://github.com/apollographql/apollo-client/pull/12396) [`00f3d0a`](https://github.com/apollographql/apollo-client/commit/00f3d0a674eede1f909092283041cf8ac8d1b576) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `errors` property from `useQuery` and `useLazyQuery`. Read errors from the `error` property instead.
389
+
390
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.getContext` now returns a `Readonly<OperationContext>` type.
391
+
392
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `ApolloLink.Request` (i.e. `GraphQLRequest`) passed to `ApolloLink.execute` no longer accepts `operationName` and `operationType` options. These properties are derived from the `query` and set on the returned `ApolloLink.Operation` type.
393
+
394
+ - [#12712](https://github.com/apollographql/apollo-client/pull/12712) [`bbb2b61`](https://github.com/apollographql/apollo-client/commit/bbb2b61d259da54560a79813b130a977dae10523) Thanks [@jerelmiller](https://github.com/jerelmiller)! - An error is now thrown when trying to call `fetchMore` on a `cache-only` query.
395
+
396
+ - [#12222](https://github.com/apollographql/apollo-client/pull/12222) [`d1a9054`](https://github.com/apollographql/apollo-client/commit/d1a905461d4378522c3257de00afba2ae8decd22) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Drop support for React 16.
397
+
398
+ - [#12787](https://github.com/apollographql/apollo-client/pull/12787) [`8ce31fa`](https://github.com/apollographql/apollo-client/commit/8ce31fae54b1ae76c557f361cc946858cb2ff66b) Thanks [@phryneas](https://github.com/phryneas)! - Remove `DataProxy` namespace and interface.
399
+
400
+ - [#12450](https://github.com/apollographql/apollo-client/pull/12450) [`876d070`](https://github.com/apollographql/apollo-client/commit/876d07042cf3348b3769b2bb415aa5f70ce9844c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `TSerialized` generic argument to `ApolloCache`. The `ApolloCache` base cache abstraction now returns `unknown` for `cache.extract` which can be overridden by a cache subclass.
401
+
402
+ - [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `getCacheKey` function is no longer available from `operation.getContext()` in the link chain. Use `operation.client.cache.identify(obj)` in the link chain instead.
403
+
404
+ - [#12376](https://github.com/apollographql/apollo-client/pull/12376) [`a0c996a`](https://github.com/apollographql/apollo-client/commit/a0c996a816fbb6a2323231c0422d1c8a3e20cbaf) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `ignoreResults` option from `useMutation`. If you don't want to synchronize component state with the mutation, use `useApolloClient` to access your client instance and use `client.mutate` directly.
405
+
406
+ - [#12644](https://github.com/apollographql/apollo-client/pull/12644) [`fe2f005`](https://github.com/apollographql/apollo-client/commit/fe2f005c34913ae082b96a807dc240e2785d50bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - More strictly adhere to the [GraphQL over HTTP spec](https://graphql.github.io/graphql-over-http/draft/). This change adds support for the `application/graphql-response+json` media type and modifies the behavior of the `application/json` media type.
407
+
408
+ - The client will parse the response as a well-formed GraphQL response when the server encodes `content-type` using `application/graphql-response+json` with a non-200 status code.
409
+ - The client will now throw a `ServerError` when the server encodes `content-type` using `application/json` and returns a non-200 status code.
410
+ - The client will now throw a `ServerError` when the server encodes using any other `content-type` and returns a non-200 status code.
411
+
412
+ NOTE: If you use a testing utility to mock requests in your test, you may experience different behavior than production if your testing utility responds as `application/json` but your production server responds as `application/graphql-response+json`. If a `content-type` header is not set, the client interprets the response as `application/json`.
413
+
414
+ - [#12600](https://github.com/apollographql/apollo-client/pull/12600) [`34ff6aa`](https://github.com/apollographql/apollo-client/commit/34ff6aa25b47c3e84d0b18e2c69bc995814bf2f2) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move most of the utilities in `@apollo/client/utilities` to `@apollo/client/utilities/internal`. Many of the utilities exported from the `@apollo/client/utilities` endpoint were not considered stable.
415
+
416
+ As a result of this change, utilities or types exported from `@apollo/client/utilities` are now documented and considered stable and will not undergo breaking changes.
417
+
418
+ - [#12513](https://github.com/apollographql/apollo-client/pull/12513) [`9c3207c`](https://github.com/apollographql/apollo-client/commit/9c3207c44ddad1f8b845c09495d6c070ace8de7b) Thanks [@phryneas](https://github.com/phryneas)! - Removed the `@apollo/client/react/context` and `@apollo/client/react/hooks` entry points. Please use `@apollo/client/react` instead.
419
+
420
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Unusubscribing from `ObservableQuery` while a request is in flight will no longer terminate the request by unsubscribing from the link observable.
421
+
422
+ - [#12463](https://github.com/apollographql/apollo-client/pull/12463) [`3868df8`](https://github.com/apollographql/apollo-client/commit/3868df81f973dc7b5a79fadf4dc1b0e291003b7f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.setOptions` has been removed as it was an alias of `reobserve`. Prefer using `reobserve` directly instead.
423
+
424
+ ```diff
425
+ const observable = client.watchQuery(options);
426
+
427
+ // Use reobserve to set new options and reevaluate the query
428
+ - observable.setOptions(newOptions);
429
+ + observable.reobserve(newOptions);
430
+ ```
431
+
432
+ As a result of this change, `reobserve` has been marked for public use and is no longer considered an internal API. The `newNetworkStatus` argument has been removed to facilitate this change.
433
+
434
+ - [#12478](https://github.com/apollographql/apollo-client/pull/12478) [`5ea6a45`](https://github.com/apollographql/apollo-client/commit/5ea6a45b3ec2f0d526abe78ae03c42bb519f87c7) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `variables` from the result returned from `useSubscription`.
435
+
436
+ - [#12735](https://github.com/apollographql/apollo-client/pull/12735) [`5159880`](https://github.com/apollographql/apollo-client/commit/51598808851e16af722baaefbd1f90534332e07a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `resultCacheMaxSize` option from `InMemoryCache` options.
437
+
438
+ - [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - The `ApolloClient` constructor options `name` and `version` that are used to
439
+ configure the client awareness feature have moved onto a `clientAwareness` key.
440
+
441
+ ```diff
442
+ const client = new ApolloClient({
443
+ // ..
444
+ - name: "my-app",
445
+ - version: "1.0.0",
446
+ + clientAwareness: {
447
+ + name: "my-app",
448
+ + version: "1.0.0",
449
+ + },
450
+ });
451
+ ```
452
+
453
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `previousData` property on `useLazyQuery` will now change only when `data` changes. Previously `previousData` would change to the same value as `data` while the query was loading.
454
+
455
+ - [#12690](https://github.com/apollographql/apollo-client/pull/12690) [`5812759`](https://github.com/apollographql/apollo-client/commit/5812759b6659df49277635e89492c0d72c3b57d6) Thanks [@phryneas](https://github.com/phryneas)! - Aliasing any other field to `__typename` is now forbidden.
456
+
457
+ - [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery` will now keep previous `data` around when emitting a `loading` state, unless `query` or `variables` changed.
458
+ Note that `@exports` variables are not taken into account for this, so `data` will stay around even if they change.
459
+
460
+ - [#12776](https://github.com/apollographql/apollo-client/pull/12776) [`bce9b74`](https://github.com/apollographql/apollo-client/commit/bce9b7448a226b109cbe8f14911503fb09f37825) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Report masked fragments as complete even when a nested masked fragment contains partial data.
461
+
462
+ - [#12788](https://github.com/apollographql/apollo-client/pull/12788) [`4179446`](https://github.com/apollographql/apollo-client/commit/417944677d2e79606b0f6cabd8d5d8b2063c876b) Thanks [@phryneas](https://github.com/phryneas)! - `TVariables` now always `extends OperationVariables` in all interfaces.
463
+
464
+ - [#12224](https://github.com/apollographql/apollo-client/pull/12224) [`51e6c0f`](https://github.com/apollographql/apollo-client/commit/51e6c0f8657d20cedc570c6e9a244f877047dd61) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `partialRefetch` option.
465
+
466
+ - [#12407](https://github.com/apollographql/apollo-client/pull/12407) [`8b1390b`](https://github.com/apollographql/apollo-client/commit/8b1390bf0050c6bd4d5a32b67c3b96369d0552d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Calling `refetch` with new variables will now set the `networkStatus` to `refetch` instead of `setVariables`.
467
+
468
+ - [#12476](https://github.com/apollographql/apollo-client/pull/12476) [`6afff60`](https://github.com/apollographql/apollo-client/commit/6afff60beece953406af2cbe07f7ccbf973cadaa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Subscriptions now emit a `SubscribeResult` instead of a `FetchResult`. As a result, the `errors` field has been removed in favor of `error`.
469
+
470
+ - [#12457](https://github.com/apollographql/apollo-client/pull/12457) [`32e85ea`](https://github.com/apollographql/apollo-client/commit/32e85ea9eb93c1ffb10d6f70e9e2775e1326e9aa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Network errors triggered by queries now adhere to the `errorPolicy`. This means that GraphQL errors and network errors now behave the same way. Previously promise-based APIs, such as `client.query`, would reject the promise with the network error even if `errorPolicy` was set to `ignore`. The promise is now resolved with the `error` property set to the network error instead.
471
+
472
+ - [#12840](https://github.com/apollographql/apollo-client/pull/12840) [`83e132a`](https://github.com/apollographql/apollo-client/commit/83e132ab1bacb3293da61dd4519379e36a1fb090) Thanks [@phryneas](https://github.com/phryneas)! - If you use an incremental delivery handler, you now have to explicitly opt into adding the chunk types to the `ApolloLink.Result` type.
473
+
474
+ ```ts title="apollo-client.d.ts
475
+ import { Defer20220824Handler } from "@apollo/client/incremental";
476
+
477
+ declare module "@apollo/client" {
478
+ export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {}
479
+ }
480
+ ```
481
+
482
+ - [#12712](https://github.com/apollographql/apollo-client/pull/12712) [`bbb2b61`](https://github.com/apollographql/apollo-client/commit/bbb2b61d259da54560a79813b130a977dae10523) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache-only` queries are no longer refetched when calling `client.reFetchObservableQueries` when `includeStandby` is `true`.
483
+
484
+ - [#12808](https://github.com/apollographql/apollo-client/pull/12808) [`8e31a23`](https://github.com/apollographql/apollo-client/commit/8e31a2303b18f6fc4d8ec1cf4c01bf26b90f3f0b) Thanks [@phryneas](https://github.com/phryneas)! - HTTP Multipart handling will now throw an error if the connection closed before the final boundary has been received.
485
+ Data after the final boundary will be ignored.
486
+
487
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `iterateObserversSafely` utility function.
488
+
489
+ - [#12825](https://github.com/apollographql/apollo-client/pull/12825) [`292b949`](https://github.com/apollographql/apollo-client/commit/292b949e9e1d10a715e0fd403737361f91432fbf) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `serializeFetchParameter` helper is no longer exported and `JSON.stringify` is used directly. As such, the `ClientParseError` type has also been removed in favor of throwing any JSON serialize errors directly.
490
+
491
+ - [#12595](https://github.com/apollographql/apollo-client/pull/12595) [`60bb49c`](https://github.com/apollographql/apollo-client/commit/60bb49ccea9aecf3e6a212b5a1f71907e60af886) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `@apollo/client/testing/experimental` test utilities. Use [GraphQL Testing Library](https://github.com/apollographql/graphql-testing-library) instead.
492
+
493
+ - [#12718](https://github.com/apollographql/apollo-client/pull/12718) [`ecfc02a`](https://github.com/apollographql/apollo-client/commit/ecfc02a37908b58d1f799f0e817cdeab98482720) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump only to release latest as `rc`.
494
+
495
+ - [#12470](https://github.com/apollographql/apollo-client/pull/12470) [`d32902f`](https://github.com/apollographql/apollo-client/commit/d32902f26a4c5dea30421ee52aeea52df3e5334e) Thanks [@phryneas](https://github.com/phryneas)! - `ssrMode`, `ssrForceFetchDelay` and `disableNetworkFetches` have been reworked:
496
+
497
+ Previously, a `ObservableQuery` created by `client.query` or `client.watchQuery`
498
+ while one of those were active would permanently be changed from a `fetchPolicy`
499
+ of `"network-only"` or `"cache-and-network"` to `"cache-first"`, and stay that way
500
+ even long after `disableNetworkFetches` would have been deactivated.
501
+
502
+ Now, the `ObservableQuery` will keep their original `fetchPolicy`, but queries
503
+ made during `disableNetworkFetches` will just apply the `fetchPolicy` replacement
504
+ at request time, just for that one request.
505
+
506
+ `ApolloClient.disableNetworkFetches` has been renamed to `ApolloClient.prioritizeCacheValues` to better reflect this behaviour.
507
+
508
+ - [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.variables` can now be reset back to empty when calling `reobserve` with `variables: undefined`. Previously the `variables` key would be ignored so `variables` would remain unchanged.
509
+
510
+ - [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `never` is no longer supported as a valid `TVariables` generic argument for APIs that require `variables` as part of its type. Use `Record<string, never>` instead.
511
+
512
+ - [#12735](https://github.com/apollographql/apollo-client/pull/12735) [`5159880`](https://github.com/apollographql/apollo-client/commit/51598808851e16af722baaefbd1f90534332e07a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `connectToDevtools` option from `ApolloClientOptions`. Use `devtools.enabled` instead.
513
+
514
+ - [#12576](https://github.com/apollographql/apollo-client/pull/12576) [`a92ff78`](https://github.com/apollographql/apollo-client/commit/a92ff780abee60896bb9632867e90c82d0829255) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `cache` and `forceFetch` properties are no longer available on context when calling `operation.getContext()`. `cache` can be accessed through the `operation` with `operation.client.cache` instead. `forceFetch` has been replaced with `queryDeduplication` which specifies whether `queryDeduplication` was enabled for the request or not.
515
+
516
+ - [#12533](https://github.com/apollographql/apollo-client/pull/12533) [`73221d8`](https://github.com/apollographql/apollo-client/commit/73221d87bd5640986f86fe3ee50c63ed49834cbb) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `onError` and `setOnError` methods from `ApolloLink`. `onError` was only used by `MockLink` to rewrite errors if `setOnError` was used.
517
+
518
+ - [#12485](https://github.com/apollographql/apollo-client/pull/12485) [`d338303`](https://github.com/apollographql/apollo-client/commit/d3383033d306b7d66e90f5f3170c24453cd76464) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Throw an error for queries and mutations if the link chain completes without emitting a value.
519
+
520
+ - [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - Removed `getLastResult`, `getLastError` and `resetLastResults` from `ObservableQuery`
521
+
522
+ - [#12663](https://github.com/apollographql/apollo-client/pull/12663) [`01512f2`](https://github.com/apollographql/apollo-client/commit/01512f2429dd394fb72b8ba9284047a09ade666f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Unsubscribing from an `ObservableQuery` before a value has been emitted will remove the query from the tracked list of queries and will no longer be eligible for query deduplication.
523
+
524
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.operationType` is now a non-null `OperationTypeNode`. It is now safe to compare this value without having to check for `undefined`.
525
+
526
+ - [#12398](https://github.com/apollographql/apollo-client/pull/12398) [`8cf5077`](https://github.com/apollographql/apollo-client/commit/8cf5077bed1ab46fdd32c5e253071506c0076064) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Apollo Client no longer wraps errors in `ApolloError`. `ApolloError` has been replaced with separate error classes depending on the cause of the error. As such, APIs that return an `error` property have been updated to use the generic `Error` type. Use `instanceof` to check for more specific error types.
527
+
528
+ ## Migration guide
529
+
530
+ `ApolloError` encapsulated 4 main error properties. The type of error would determine which property was set:
531
+
532
+ - `graphqlErrors` - Errors returned from the `errors` field by the GraphQL server
533
+ - `networkError` - Any non-GraphQL error that caused the query to fail
534
+ - `protocolErrors` - Transport-level errors that occur during [multipart HTTP subscriptions](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol)
535
+ - `clientErrors` - A space to define custom errors. Mostly unused.
536
+
537
+ These errors were mutally exclusive, meaning both `networkError` and `graphqlErrors` were never set simultaneously. The following replaces each of these fields from `ApolloError`.
538
+
539
+ ### `graphqlErrors`
540
+
541
+ GraphQL errors are now encapsulated in a `CombinedGraphQLErrors` instance. You can access the raw GraphQL errors via the `errors` property.
542
+
543
+ ```js
544
+ import { CombinedGraphQLErrors } from "@apollo/client";
545
+
546
+ // ...
547
+
548
+ const { error } = useQuery(query);
549
+
550
+ if (error && error instanceof CombinedGraphQLErrors) {
551
+ console.log(error.errors);
552
+ }
553
+ ```
554
+
555
+ ### `networkError`
556
+
557
+ Network errors are no longer wrapped and are instead passed through directly.
558
+
559
+ ```js
560
+ const client = new ApolloClient({
561
+ link: new ApolloLink(() => {
562
+ return new Observable((observer) => {
563
+ observer.error(new Error("Test error"));
564
+ });
565
+ }),
566
+ });
567
+
568
+ // ...
569
+
570
+ const { error } = useQuery(query);
571
+
572
+ // error is `new Error('Test error')`;
573
+ ```
574
+
575
+ ### `protocolErrors`
576
+
577
+ Protocol errors are now encapsulated in a `CombinedProtocolErrors` instance. You can access the raw protocol errors via the `errors` property.
578
+
579
+ ```js
580
+ import { CombinedProtocolErrors } from "@apollo/client";
581
+
582
+ // ...
583
+
584
+ const { error } = useSubscription(subscription);
585
+
586
+ if (error && error instanceof CombinedProtocolErrors) {
587
+ console.log(error.errors);
588
+ }
589
+ ```
590
+
591
+ ### `clientErrors`
592
+
593
+ These were unused by the client and have no replacement. Any non-GraphQL or non-protocol errors are now passed through unwrapped.
594
+
595
+ ### Strings as errors
596
+
597
+ If the link sends a string error, Apollo Client will wrap this in an `Error` instance. This ensures `error` properties are guaranteed to be of type `Error`.
598
+
599
+ ```js
600
+ const client = new ApolloClient({
601
+ link: new ApolloLink(() => {
602
+ return new Observable((observer) => {
603
+ // Oops we sent a string instead of wrapping it in an `Error`
604
+ observer.error("Test error");
605
+ });
606
+ }),
607
+ });
608
+
609
+ // ...
610
+
611
+ const { error } = useQuery(query);
612
+
613
+ // The error string is wrapped and returned as `new Error('Test error')`;
614
+ ```
615
+
616
+ ### Non-error types
617
+
618
+ If the link chain sends any other object type as an error, Apollo Client will wrap this in an `UnknownError` instance with the [`cause`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) set to the original object. This ensures `error` properties are guaranteed to be of type `Error`.
619
+
620
+ ```js
621
+ const client = new ApolloClient({
622
+ link: new ApolloLink(() => {
623
+ return new Observable((observer) => {
624
+ observer.error({ message: "Not a proper error type" });
625
+ });
626
+ }),
627
+ });
628
+
629
+ // ...
630
+
631
+ const { error } = useQuery(query);
632
+
633
+ // error is an `UnknownError` instance. error.cause returns the original object.
634
+ ```
635
+
636
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.operationName` is now set as `string | undefined` where `undefined` represents an anonymous query. Previously `operationName` would return an empty string as the `operationName` for anonymous queries.
637
+
638
+ - [#12450](https://github.com/apollographql/apollo-client/pull/12450) [`876d070`](https://github.com/apollographql/apollo-client/commit/876d07042cf3348b3769b2bb415aa5f70ce9844c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `TCacheShape` generic argument to `ApolloClient`. `client.extract()` now returns `unknown` by default. You will either need to type-cast this to the expected serialized shape, or use the `cache.extract()` directly from the subclass to get more specific types.
639
+
640
+ - [#12774](https://github.com/apollographql/apollo-client/pull/12774) [`511b4f3`](https://github.com/apollographql/apollo-client/commit/511b4f3e792a75aa5aa27b335e8119dbc2a9c254) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Apply document transforms before reading data from the cache for `client.readQuery`, `client.readFragment`, `client.watchFragment`, `useFragment`, and `useSuspenseFragment`.
641
+
642
+ NOTE: This change does not affect the equivalent `cache.*` APIs. To read data from the cache without first running document transforms, run `cache.readQuery`, `cache.readFragment`, etc.
643
+
644
+ - [#12705](https://github.com/apollographql/apollo-client/pull/12705) [`a60f411`](https://github.com/apollographql/apollo-client/commit/a60f411e58cc67730d0dc4513e4045f004027ded) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache-only` queries will now initialize with `loading: false` and `networkStatus: NetworkStatus.ready` when there is no data in the cache.
645
+
646
+ This means `useQuery` will no longer render a short initial loading state before rendering `loading: false` and `ObservableQuery.getCurrentResult()` will now return `loading: false` immediately.
647
+
648
+ - [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Unify error behavior on mutations for GraphQL errors and network errors by ensuring network errors are subject to the `errorPolicy`. Network errors created when using an `errorPolicy` of `all` will now resolve the promise and be returned on the `error` property of the result, or stripped away when the `errorPolicy` is `none`.
649
+
650
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `fromError` utility function. Use [`throwError`](https://rxjs.dev/api/index/function/throwError) instead.
651
+
652
+ - [#12649](https://github.com/apollographql/apollo-client/pull/12649) [`0be92ad`](https://github.com/apollographql/apollo-client/commit/0be92ad51cf8de444fa1cc507bab2c21d230a44e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `TData` generic provided to types that return a `dataState` property is now modified by the given `DataState` generic instead of passing a modified `TData` type. For example, a `QueryRef` that could return partial data was defined as `QueryRef<DeepPartial<TData>, TVariables>`. Now `TData` should be provided unmodified and a set of allowed states should be given instead: `QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'>`.
653
+
654
+ To migrate, use the following guide to replace your type with the right set of states (all types listed below are changed the same way):
655
+
656
+ ```diff
657
+ - QueryRef<TData, TVariables>
658
+ // `QueryRef`'s default is 'complete' | 'streaming' so this can also be left alone if you prefer
659
+ // All other types affected by this change default to all states
660
+ + QueryRef<TData, TVariables>
661
+ + QueryRef<TData, TVariables, 'complete' | 'streaming'>
662
+
663
+ - QueryRef<TData | undefined, TVariables>
664
+ + QueryRef<TData, TVariables, 'complete' | 'streaming' | 'empty'>
665
+
666
+ - QueryRef<DeepPartial<TData>, TVariables>
667
+ + QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'>
668
+
669
+ - QueryRef<DeepPartial<TData> | undefined, TVariables>
670
+ + QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial' | 'empty'>
671
+ ```
672
+
673
+ The following types are affected. Provide the allowed `dataState` values to the `TDataState` generic:
674
+
675
+ - `ApolloQueryResult`
676
+ - `QueryRef`
677
+ - `PreloadedQueryRef`
678
+ - `useLazyQuery.Result`
679
+ - `useQuery.Result`
680
+ - `useReadQuery.Result`
681
+ - `useSuspenseQuery.Result`
682
+
683
+ All `*QueryRef` types default to `complete | streaming` states while the rest of the types default to `'complete' | 'streaming' | 'partial' | 'empty'` states. You shouldn't need to provide the states unless you need to either allow for partial data/empty values (`*QueryRef`) or a restricted set of states.
684
+
685
+ - [#12850](https://github.com/apollographql/apollo-client/pull/12850) [`268cd80`](https://github.com/apollographql/apollo-client/commit/268cd800a2d73305c0df8dd38b6bd1cee98f0fec) Thanks [@phryneas](https://github.com/phryneas)! - Introduce a versioning policy.
686
+
687
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `concat`, `from`, and `split` functions on `ApollLink` no longer support a plain request handler function. Please wrap the request handler with `new ApolloLink`.
688
+
689
+ ```diff
690
+ const link = new ApolloLink(/* ... */);
691
+
692
+ link.concat(
693
+ - (operation, forward) => forward(operation),
694
+ + new ApolloLink((operation, forward) => forward(operation)),
695
+ );
696
+ ```
697
+
698
+ - [#12802](https://github.com/apollographql/apollo-client/pull/12802) [`e2b51b3`](https://github.com/apollographql/apollo-client/commit/e2b51b30acbd360253100f9d2a91fe7e0c57be4c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Disallow the `mutation` option for the `mutate` function returned from `useMutation`.
699
+
700
+ - [#12211](https://github.com/apollographql/apollo-client/pull/12211) [`c2736db`](https://github.com/apollographql/apollo-client/commit/c2736db3ad6f8b6e56f065682d5b76614f41bfd4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `graphql`, `withQuery`, `withMutation`, `withSubscription`, and `withApollo` hoc components. Use the provided React hooks instead.
701
+
702
+ - [#12690](https://github.com/apollographql/apollo-client/pull/12690) [`5812759`](https://github.com/apollographql/apollo-client/commit/5812759b6659df49277635e89492c0d72c3b57d6) Thanks [@phryneas](https://github.com/phryneas)! - Aliasing a field to an alias beginning with `__ac_` is now forbidden - this namespace is now reserved for internal use.
703
+
704
+ - [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - When passing a `variables` key with the value `undefined`, the value will be replaced by the default value in the query, if it is provided, rather than leave it as `undefined`.
705
+
706
+ ```ts
707
+ // given this query
708
+ const query = gql`
709
+ query PaginatedQuery($limit: Int! = 10, $offset: Int) {
710
+ list(limit: $limit, offset: $offset) {
711
+ id
712
+ }
713
+ }
714
+ `;
715
+
716
+ const observable = client.query({
717
+ query,
718
+ variables: { limit: 5, offset: 0 },
719
+ });
720
+ console.log(observable.variables); // => { limit: 5, offset: 0 }
721
+
722
+ observable.reobserve({ variables: { limit: undefined, offset: 10 } });
723
+ // limit is now `10`. This would previously be `undefined`
724
+ console.log(observable.variables); // => { limit: 10, offset: 10 }
725
+ ```
726
+
727
+ - [#12262](https://github.com/apollographql/apollo-client/pull/12262) [`10ef733`](https://github.com/apollographql/apollo-client/commit/10ef7338cdcbbaf75d806f426e9708c9e095c2da) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `itAsync` test utility.
728
+
729
+ - [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - Adds enhanced client awareness to the client.
730
+
731
+ `HttpLink` and `BatchHttpLink` will now per default send information about the
732
+ client library you are using in `extensions`.
733
+
734
+ This could look like this:
735
+
736
+ ```json
737
+ {
738
+ "query": "query GetUser($id: ID!) { user(id: $id) { __typename id name } }",
739
+ "variables": {
740
+ "id": 5
741
+ },
742
+ "extensions": {
743
+ "clientLibrary": {
744
+ "name": "@apollo/client",
745
+ "version": "4.0.0"
746
+ }
747
+ }
748
+ }
749
+ ```
750
+
751
+ This feature can be disabled by passing `enhancedClientAwareness: { transport: false }` to your
752
+ `ApolloClient`, `HttpLink` or `BatchHttpLink` constructor options.
753
+
754
+ - [#12742](https://github.com/apollographql/apollo-client/pull/12742) [`575bf3e`](https://github.com/apollographql/apollo-client/commit/575bf3ed5885efb09c1eec497af4d2690c6b87d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The new `SetContextLink` flips the `prevContext` and `operation` arguments in the callback. The `setContext` function has remained unchanged.
755
+
756
+ ```diff
757
+ - new SetContextLink((operation, prevContext) => {
758
+ + new SetContextLink((prevContext, operation) => {
759
+ // ...
760
+ })
761
+ ```
762
+
763
+ - [#12536](https://github.com/apollographql/apollo-client/pull/12536) [`e14205a`](https://github.com/apollographql/apollo-client/commit/e14205ad5909f95aa04684acd0ca2f25956ee50c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - An initial loading state is now emitted from `ObservableQuery` when subscribing if `notifyOnNetworkStatusChange` is set to `true`.
764
+
765
+ - [#12465](https://github.com/apollographql/apollo-client/pull/12465) [`a132163`](https://github.com/apollographql/apollo-client/commit/a1321637cafb4023d6df416e9467294114d8346b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Flatten out React hook types. As a result, the base types have been removed. Prefer using the hook types instead. Removed types include:
766
+
767
+ - `BaseMutationOptions`
768
+ - `BaseQueryOptions`
769
+ - `BaseSubscriptionOptions`
770
+ - `ObservableQueryFields`
771
+ - `MutationSharedOptions`
772
+ - `QueryFunctionOptions`
773
+
774
+ - [#12675](https://github.com/apollographql/apollo-client/pull/12675) [`8f1d974`](https://github.com/apollographql/apollo-client/commit/8f1d974881ff54339b6b6593a219ba6d5fd013c0) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery` no longer has a `queryId` property.
775
+ `ApolloClient.getObservableQueries` no longer returns a `Map<string, ObservableQuery>`, but a `Set<ObservableQuery>`.
776
+
777
+ - [#12398](https://github.com/apollographql/apollo-client/pull/12398) [`8cf5077`](https://github.com/apollographql/apollo-client/commit/8cf5077bed1ab46fdd32c5e253071506c0076064) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Updates the `ServerError` and `ServerParseError` types to be proper `Error` subclasses. Perviously these were plain `Error` intances with additional properties added at runtime. All properties are retained, but `instanceof` checks now work correctly.
778
+
779
+ ```js
780
+ import { ServerError, ServerParseError } from "@apollo/client";
781
+
782
+ if (error instanceof ServerError) {
783
+ // ...
784
+ }
785
+
786
+ if (error instanceof ServerParseError) {
787
+ // ...
788
+ }
789
+ ```
790
+
791
+ - [#12712](https://github.com/apollographql/apollo-client/pull/12712) [`bbb2b61`](https://github.com/apollographql/apollo-client/commit/bbb2b61d259da54560a79813b130a977dae10523) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache-only` queries are now excluded from `client.refetchQueries` in all situations. `cache-only` queries affected by `updateCache` are also excluded from `refetchQueries` when `onQueryUpdated` is not provided.
792
+
793
+ - [#12463](https://github.com/apollographql/apollo-client/pull/12463) [`3868df8`](https://github.com/apollographql/apollo-client/commit/3868df81f973dc7b5a79fadf4dc1b0e291003b7f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useQuery` no longer returns `reobserve` as part of its result. It was possible to use `reobserve` to set new options on the underlying `ObservableQuery` instance which differed from the options passed to the hook. This could result in unexpected results. Instead prefer to rerender the hook with new options.
794
+
795
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` no longer supports SSR environments and will now throw if the `execute` function is called in SSR. If you need to run a query in an SSR environment, use `useQuery` instead.
796
+
797
+ - [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `resolvers` option from `ApolloClient`. Local resolvers have instead been moved to the new `LocalState` instance which is assigned to the `localState` option in `ApolloClient`. To migrate, move the `resolvers` values into a `LocalState` instance and assign that instance to `localState`.
798
+
799
+ ```diff
800
+ new ApolloClient({
801
+ - resolvers: { /* ... */ }
802
+ + localState: new LocalState({
803
+ + resolvers: { /* ... */ }
804
+ + }),
805
+ });
806
+ ```
807
+
808
+ - [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `client.mutate` now returns a `MutateResult` instead of `FetchResult`. As a result, the `errors` property has been removed in favor of `error` which is set if either a network error occured or GraphQL errors are returned from the server.
809
+
810
+ `useMutation` now also returns a `MutateResult` instead of a `FetchResult`.
811
+
812
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The execute function returned from `useLazyQuery` now only supports the `context` and `variables` options. This means that passing options supported by the hook no longer override the hook value.
813
+
814
+ To change options, rerender the component with new options. These options will take effect with the next query execution.
815
+
816
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery` will no longer terminate on errors and will instead emit a `next` value with an `error` property. This ensures that `ObservableQuery` instances can continue to receive updates after errors are returned in requests without the need to resubscribe to the observable.
817
+
818
+ - [#12681](https://github.com/apollographql/apollo-client/pull/12681) [`b181f98`](https://github.com/apollographql/apollo-client/commit/b181f98476e635ba3eccab170c09d91f5408060c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Changing most options when rerendering `useQuery` will no longer trigger a `reobserve` which may cause network fetches. Instead, the changed options will be applied to the next cache update or fetch.
819
+
820
+ Options that now trigger a `reobserve` when changed between renders are:
821
+
822
+ - `query`
823
+ - `variables`
824
+ - `skip`
825
+ - Changing `fetchPolicy` to or from `standby`
826
+
827
+ - [#12787](https://github.com/apollographql/apollo-client/pull/12787) [`8ce31fa`](https://github.com/apollographql/apollo-client/commit/8ce31fae54b1ae76c557f361cc946858cb2ff66b) Thanks [@phryneas](https://github.com/phryneas)! - Generic arguments for `Cache.ReadOptions` were flipped from `TVariables, TData` to `TData, TVariables`.
828
+
829
+ - [#12837](https://github.com/apollographql/apollo-client/pull/12837) [`7c49fdc`](https://github.com/apollographql/apollo-client/commit/7c49fdce2f40571d92c83602bbb1b5bd891f626b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - You must now opt in to use GraphQL Codegen data masking types when using Apollo Client's data masking feature. By default, Apollo Client now uses an identity type to apply to masked/unmasked types.
830
+
831
+ If you're using GraphQL Codegen to generate masked types, opt into the GraphQL Codegen masked types using declaration merging on the `TypeOverides` interface.
832
+
833
+ ```ts title="apollo-client.d.ts
834
+ import { GraphQLCodegenDataMasking } from "@apollo/client/masking";
835
+
836
+ declare module "@apollo/client" {
837
+ export interface TypeOverrides
838
+ extends GraphQLCodegenDataMasking.TypeOverrides {}
839
+ }
840
+ ```
841
+
842
+ - [#12824](https://github.com/apollographql/apollo-client/pull/12824) [`0506f12`](https://github.com/apollographql/apollo-client/commit/0506f12936d3fe7c840e5d56a5efa20bbce1525e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure the `error` argument for the `delay` and `attempts` functions on `RetryLink` are an `ErrorLike`.
843
+
844
+ - [#12398](https://github.com/apollographql/apollo-client/pull/12398) [`8cf5077`](https://github.com/apollographql/apollo-client/commit/8cf5077bed1ab46fdd32c5e253071506c0076064) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `throwServerError` utility function. Now that `ServerError` is an
845
+ `Error` subclass, you can throw these errors directly:
846
+
847
+ ```js
848
+ import { ServerError } from "@apollo/client";
849
+
850
+ // instead of
851
+ throwServerError(response, result, "error message");
852
+
853
+ // Use
854
+ throw new ServerError("error message", { response, result });
855
+ ```
856
+
857
+ - [#12837](https://github.com/apollographql/apollo-client/pull/12837) [`7c49fdc`](https://github.com/apollographql/apollo-client/commit/7c49fdce2f40571d92c83602bbb1b5bd891f626b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The types mode for data masking has been removed. Adding a types mode to the `DataMasking` interface has no effect. Remove the `mode` key in the module where you declare the `DataMasking` type for the `@apollo/client` module.
858
+
859
+ As a result, the `Masked` and `MaskedDocumentNode` types have also been removed since these have no effect when types are preserved.
860
+
861
+ - [#12304](https://github.com/apollographql/apollo-client/pull/12304) [`86469a2`](https://github.com/apollographql/apollo-client/commit/86469a25abb72dbd68adff3554e3909036e77eee) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `Cache.DiffResult<T>` type is now a union type with better type safety for both complete and partial results. Checking `diff.complete` will now narrow the type of `result` depending on whether the value is `true` or `false`.
862
+
863
+ When `true`, `diff.result` will be a non-null value equal to the `T` generic type. When `false`, `diff.result` now reports `result` as `DeepPartial<T> | null` indicating that fields in the result may be missing (`DeepPartial<T>`) or empty entirely (`null`).
864
+
865
+ - [#12731](https://github.com/apollographql/apollo-client/pull/12731) [`0198870`](https://github.com/apollographql/apollo-client/commit/0198870107eab7ad0bc69a549cb069fa41b3280f) Thanks [@phryneas](https://github.com/phryneas)! - Ship React Compiler compiled React hooks in `@apollo/client/react/compiled`.
866
+
867
+ We now ship a React-Compiler compiled version of the React hooks in
868
+ `@apollo/client/react/compiled`.
869
+
870
+ This entry point contains everything that `@apollo/client/react` does,
871
+ so you can use it as a drop-in replacement in your whole application
872
+ if you choose to use the compiled hooks.
873
+
874
+ - [#12446](https://github.com/apollographql/apollo-client/pull/12446) [`ab920d2`](https://github.com/apollographql/apollo-client/commit/ab920d2701aa276482dbc78b44a1c25c76467bc9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `defaultOptions` option from `useQuery`. Use options directly or use the global `ApolloClient` `defaultOptions`.
875
+
876
+ - [#12649](https://github.com/apollographql/apollo-client/pull/12649) [`0be92ad`](https://github.com/apollographql/apollo-client/commit/0be92ad51cf8de444fa1cc507bab2c21d230a44e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `QueryReference` type. Please use `QueryRef` instead.
877
+
878
+ - [#12396](https://github.com/apollographql/apollo-client/pull/12396) [`00f3d0a`](https://github.com/apollographql/apollo-client/commit/00f3d0a674eede1f909092283041cf8ac8d1b576) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `errors` property from the results emitted from `ObservableQuery` or returned from `client.query`. Read errors from the `error` property instead.
879
+
880
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The result resolved from the promise returned from the execute function in `useLazyQuery` is now an `ApolloQueryResult` type and no longer includes all the fields returned from the `useLazyQuery` hook tuple.
881
+
882
+ If you need access to the additional properties such as `called`, `refetch`, etc. not included in `ApolloQueryResult`, read them from the hook instead.
883
+
884
+ - [#12531](https://github.com/apollographql/apollo-client/pull/12531) [`7784b46`](https://github.com/apollographql/apollo-client/commit/7784b46117a4f91a270a020ed1a24f042cb9ee17) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Mocked responses passed to `MockLink` now accept a callback for the `request.variables` option. This is used to determine if the mock should be matched for a set of request variables. With this change, the `variableMatcher` option has been removed in favor of passing a callback to `variables`. Update by moving the callback function from `variableMatcher` to `request.variables`.
885
+
886
+ ```diff
887
+ new MockLink([
888
+ {
889
+ request: {
890
+ query,
891
+ + variables: (requestVariables) => true
892
+ },
893
+ - variableMatcher: (requestVariables) => true
894
+ }
895
+ ]);
896
+ ```
897
+
898
+ - [#12793](https://github.com/apollographql/apollo-client/pull/12793) [`24e98a1`](https://github.com/apollographql/apollo-client/commit/24e98a16648d4c21f37ba51a678a8849f88174ea) Thanks [@phryneas](https://github.com/phryneas)! - `ApolloConsumer` has been removed - please use `useApolloClient` instead.
899
+
900
+ - [#12714](https://github.com/apollographql/apollo-client/pull/12714) [`0e39469`](https://github.com/apollographql/apollo-client/commit/0e394692eaf0f8d8e506d8304935deafa952accf) Thanks [@phryneas](https://github.com/phryneas)! - Rework option handling for `fetchMore`.
901
+
902
+ - Previously, if the `query` option was specified, no options would be inherited
903
+ from the underlying `ObservableQuery`.
904
+ Now, even if `query` is specified, all unspecified options except for `variables` will be inherited from the underlying `ObservableQuery`.
905
+ - If `query` is not specified, `variables` will still be shallowly merged with the `variables` of the underlying `ObservableQuery`. If a `query` option is specified, the `variables` passed to `fetchMore` are used instead.
906
+ - `errorPolicy` of `fetchMore` will now always default to `"none"` instead of inherited from the `ObservableQuery` options. This can prevent accidental cache writes of partial data for a paginated query. To opt into receive partial data that may be written to the cache, pass an `errorPolicy` to `fetchMore` to override the default.
907
+
908
+ - [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove local resolvers APIs from `ApolloClient` in favor of `localState`. Methods removed are:
909
+
910
+ - `addResolvers`
911
+ - `getResolvers`
912
+ - `setResolvers`
913
+ - `setLocalStateFragmentMatcher`
914
+
915
+ - [#12576](https://github.com/apollographql/apollo-client/pull/12576) [`a92ff78`](https://github.com/apollographql/apollo-client/commit/a92ff780abee60896bb9632867e90c82d0829255) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ApolloLink.execute` now requires a third argument which provides the `client` that initiated the request to the link chain. If you use `execute` directly, add a third argument with a `client` property:
916
+
917
+ ```ts
918
+ ApolloLink.execute(link, operation, { client });
919
+
920
+ // or if you import the `execute` function directly:
921
+ execute(link, operation, { client });
922
+ ```
923
+
924
+ - [#12526](https://github.com/apollographql/apollo-client/pull/12526) [`391af1d`](https://github.com/apollographql/apollo-client/commit/391af1dd733219b7e1e14cfff9d5e3ce3967242f) Thanks [@phryneas](https://github.com/phryneas)! - The `@apollo/client` and `@apollo/client/core` entry points are now equal.
925
+ In the next major, the `@apollo/client/core` entry point will be removed.
926
+ Please change imports over from `@apollo/client/core` to `@apollo/client`.
927
+
928
+ - [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - Added a new `Streaming` type that will mark `data` in results while `dataState`
929
+ is `"streaming"`.
930
+
931
+ `Streaming<TData>` defaults to `TData`, but can be overwritten in userland to
932
+ integrate with different codegen dialects.
933
+
934
+ You can override this type globally - this example shows how to override it
935
+ with `DeepPartial<TData>`:
936
+
937
+ ```ts
938
+ import { HKT, DeepPartial } from "@apollo/client/utilities";
939
+
940
+ type StreamingOverride<TData> = DeepPartial<TData>;
941
+
942
+ interface StreamingOverrideHKT extends HKT {
943
+ return: StreamingOverride<this["arg1"]>;
944
+ }
945
+
946
+ declare module "@apollo/client" {
947
+ export interface TypeOverrides {
948
+ Streaming: StreamingOverrideHKT;
949
+ }
950
+ }
951
+ ```
952
+
953
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` will no longer rerender with the loading state when calling the execute function the first time unless the `notifyOnNetworkStatusChange` option is set to `true` (which is the new default).
954
+
955
+ If you prefer the behavior from 3.x, rerender the component with
956
+ `notifyOnNetworkStatusChange` set to `false` after the execute function is
957
+ called the first time.
958
+
959
+ ```ts
960
+ function MyComponent() {
961
+ const [notifyOnNetworkStatusChange, setNotifyOnNetworkStatusChange] =
962
+ useState(true);
963
+ const [execute] = useLazyQuery(query, { notifyOnNetworkStatusChange });
964
+
965
+ async function runExecute() {
966
+ await execute();
967
+
968
+ // Set to false after the initial fetch to stop receiving notifications
969
+ // about changes to the loading states.
970
+ setNotifyOnNetworkStatusChange(false);
971
+ }
972
+
973
+ // ...
974
+ }
975
+ ```
976
+
977
+ - [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Mutations no longer report errors if the GraphQL result from the server contains an empty array of errors.
978
+
979
+ - [#12254](https://github.com/apollographql/apollo-client/pull/12254) [`0028ac0`](https://github.com/apollographql/apollo-client/commit/0028ac0147aaea9ab559f15630200a132b43da42) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Changes the default `Accept` header to `application/graphql-response+json`.
980
+
981
+ - [#12633](https://github.com/apollographql/apollo-client/pull/12633) [`9bfb51f`](https://github.com/apollographql/apollo-client/commit/9bfb51fdbca69560da71f9012c74ee172b6c2b69) Thanks [@phryneas](https://github.com/phryneas)! - If the `execute` function of `useLazyQuery` is executed, previously started queries
982
+ from the same `useLazyQuery` usage will be rejected with an `AbortError` unless
983
+ `.retain()` is called on the promise returned by previous `execute` calls.
984
+
985
+ Please keep in mind that `useLazyQuery` is primarily meant as a means to synchronize
986
+ your component to the status of a query and that it's purpose it not to make a
987
+ series of network calls.
988
+ If you plan on making a series of network calls without the need to synchronize
989
+ the result with your component, consider using `ApolloClient.query` instead.
990
+
991
+ - [#12513](https://github.com/apollographql/apollo-client/pull/12513) [`9c3207c`](https://github.com/apollographql/apollo-client/commit/9c3207c44ddad1f8b845c09495d6c070ace8de7b) Thanks [@phryneas](https://github.com/phryneas)! - Removed the `@apollo/client/react/parser` entry point. There is no replacement.
992
+
993
+ - [#12430](https://github.com/apollographql/apollo-client/pull/12430) [`2ff66d0`](https://github.com/apollographql/apollo-client/commit/2ff66d06b6d444fbcb46e580ac40e673e695740f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.setVariables` will now resolve with the last emitted result instead of `undefined` when either the variables match the current variables or there are no subscribers to the query.
994
+
995
+ - [#12685](https://github.com/apollographql/apollo-client/pull/12685) [`3b74800`](https://github.com/apollographql/apollo-client/commit/3b748003df89ec69a6ad045fb47bbe9c3e62104c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the check and warning for `cache.fragmentMatches` when applying data masking. `cache.fragmentMatches` is a required API and data masking may crash when `cache.fragmentMatches` does not exist.
996
+
997
+ - [#12385](https://github.com/apollographql/apollo-client/pull/12385) [`cad5117`](https://github.com/apollographql/apollo-client/commit/cad511723a1b8b0ac2042cf49435f7affb0dc4e4) Thanks [@phryneas](https://github.com/phryneas)! - Apollo Client now defaults to production mode, not development mode, if the
998
+ environment cannot be determined.
999
+
1000
+ In modern bundlers, this should automatically be handled by the bundler loading
1001
+ the bundler with the `development` export condition.
1002
+
1003
+ If neither the `production` nor the `development` export condition are
1004
+ used by the bundler/runtime, Apollo Client will fall back to `globalThis.__DEV__`
1005
+ to determine if it should run in production or development mode.
1006
+
1007
+ Unlike Apollo Client 3 though, if `globalThis.__DEV__` is not set to `true`,
1008
+ Apollo Client will now default to `production`, not to `development`, behaviour.
1009
+
1010
+ This switch to _explicilty_ requiring `true` also resolves a situation where
1011
+ an HTML element with `id="__DEV__"` would create a global `__DEV__` variable
1012
+ with a referent to the DOM element, which in the past was picked up as "truthy" and
1013
+ would have triggered development mode.
1014
+
1015
+ - [#12644](https://github.com/apollographql/apollo-client/pull/12644) [`fe2f005`](https://github.com/apollographql/apollo-client/commit/fe2f005c34913ae082b96a807dc240e2785d50bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Change the default `Accept` header to `application/graphql-response+json,application/json;q=0.9`.
1016
+
1017
+ - [#12476](https://github.com/apollographql/apollo-client/pull/12476) [`6afff60`](https://github.com/apollographql/apollo-client/commit/6afff60beece953406af2cbe07f7ccbf973cadaa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Unify error behavior on subscriptions for GraphQL errors and network errors by ensuring network errors are subject to the `errorPolicy`. Network errors that terminate the connection will now be emitted on the `error` property passed to the `next` callback followed by a call to the `complete` callback.
1018
+
1019
+ - [#12499](https://github.com/apollographql/apollo-client/pull/12499) [`ce35ea2`](https://github.com/apollographql/apollo-client/commit/ce35ea2b3a87d6dd6757e9be50ecc42837bebe56) Thanks [@phryneas](https://github.com/phryneas)! - Enable React compiler for hooks in ESM builds.
1020
+
1021
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `reobserve` option is no longer available in the result returned from `useLazyQuery`. This was considered an internal API and should not be used directly.
1022
+
1023
+ - [#12333](https://github.com/apollographql/apollo-client/pull/12333) [`3e4beaa`](https://github.com/apollographql/apollo-client/commit/3e4beaa8b768a893da80aae0428f79ee01d6aa38) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix type of `data` property on `ApolloQueryResult`. Previously this field was non-optional, non-null `TData`, however at runtime this value could be set to `undefined`. This field is now reported as `TData | undefined`.
1024
+
1025
+ This will affect you in a handful of places:
1026
+
1027
+ - The `data` property emitted from the result passed to the `next` callback from `client.watchQuery`
1028
+ - Fetch-based APIs that return an `ApolloQueryResult` type such as `observableQuery.refetch`, `observableQuery.fetchMore`, etc.
1029
+
1030
+ - [#12644](https://github.com/apollographql/apollo-client/pull/12644) [`fe2f005`](https://github.com/apollographql/apollo-client/commit/fe2f005c34913ae082b96a807dc240e2785d50bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `HttpLink` and `BatchHttpLink` no longer emit a `next` notification with the JSON-parsed response body when a well-formed GraphQL response is returned and a `ServerError` is thrown.
1031
+
1032
+ - [#12742](https://github.com/apollographql/apollo-client/pull/12742) [`575bf3e`](https://github.com/apollographql/apollo-client/commit/575bf3ed5885efb09c1eec497af4d2690c6b87d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `operation` argument to the callback passed to `SetContextLink` is now of type `SetContextLink.SetContextOperation` which is an `Operation` without the `getContext` or `setContext` functions. Previously the type of `operation` was `GraphQLRequest` which had access to a `context` property. The `context` property was always `undefined` and could result in bugs when using it instead of the `prevContext` argument.
1033
+
1034
+ This change means the `operation` argument now contains an accessible `client` property.
1035
+
1036
+ - [#12639](https://github.com/apollographql/apollo-client/pull/12639) [`1bdf489`](https://github.com/apollographql/apollo-client/commit/1bdf4893abb173c97877c71012afa15f9d3da8e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move internal testing utilities in `@apollo/client/testing` to `@apollo/client/testing/internal` and remove deprecated testing utilities. Some of the testing utilities exported from the `@apollo/client/testing` endpoint were not considered stable. As a result of this change, testing utilities or types exported from `@apollo/client/testing` are now considered stable and will not undergo breaking changes.
1037
+
1038
+ The following APIs were removed. To migrate, update usages of the following APIs as such:
1039
+
1040
+ **`createMockClient`**
1041
+
1042
+ ```diff
1043
+ - const client = createMockClient(data, query, variables);
1044
+ + const client = new ApolloClient({
1045
+ + cache: new InMemoryCache(),
1046
+ + link: new MockLink([
1047
+ + {
1048
+ + request: { query, variables },
1049
+ + result: { data },
1050
+ + }
1051
+ + ]),
1052
+ + });
1053
+ ```
1054
+
1055
+ **`mockObservableLink`**
1056
+
1057
+ ```diff
1058
+ - const link = mockObservableLink();
1059
+ + const link = new MockSubscriptionLink();
1060
+ ```
1061
+
1062
+ **`mockSingleLink`**
1063
+
1064
+ ```diff
1065
+ - const link = mockSingleLink({
1066
+ - request: { query, variables },
1067
+ - result: { data },
1068
+ - });
1069
+ + const link = new MockLink([
1070
+ + {
1071
+ + request: { query, variables },
1072
+ + result: { data },
1073
+ + }
1074
+ + ]);
1075
+ ```
1076
+
1077
+ - [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Third-party caches must now implement the `fragmentMatches` API. Additionally `fragmentMatches` must be able to handle both `InlineFragmentNode` and `FragmentDefinitionNode` nodes.
1078
+
1079
+ ```ts
1080
+ class MyCache extends ApolloCache {
1081
+ // This is now required
1082
+ public fragmentMatches(
1083
+ fragment: InlineFragmentNode | FragmentDefinitionNode,
1084
+ typename: string
1085
+ ): boolean {
1086
+ return; // ... logic to determine if typename matches fragment
1087
+ }
1088
+ }
1089
+ ```
1090
+
1091
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The promise returned when calling the execute function from `useLazyQuery` will now reject when using an `errorPolicy` of `none` when GraphQL errors are returned from the result.
1092
+
1093
+ - [#12684](https://github.com/apollographql/apollo-client/pull/12684) [`e697431`](https://github.com/apollographql/apollo-client/commit/e697431a9995fd1900e625c30a9065edd71111d9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `context` from `useLazyQuery` hook options. If used, `context` must now be provided to the `execute` function. `context` will reset to `{}` if not provided as an option to `execute`.
1094
+
1095
+ - [#12704](https://github.com/apollographql/apollo-client/pull/12704) [`45dba43`](https://github.com/apollographql/apollo-client/commit/45dba43b6ba0c306aad8cfbcfd4029265f5e9106) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `ErrorResponse` object passed to the `disable` and `retry` callback options provided to `createPersistedQueryLink` no longer provides separate `graphQLErrors` and `networkError` properties and instead have been combined to a single `error` property of type `ErrorLike`.
1096
+
1097
+ ```diff
1098
+ // The following also applies to the `retry` function since it has the same signature
1099
+ createPersistedQueryLink({
1100
+ - disable: ({ graphQLErrors, networkError }) => {
1101
+ + disable: ({ error }) => {
1102
+ - if (graphQLErrors) {
1103
+ + if (CombinedGraphQLErrors.is(error)) {
1104
+ // ... handle GraphQL errors
1105
+ }
1106
+
1107
+ - if (networkError) {
1108
+ + if (error) {
1109
+ // ... handle link errors
1110
+ }
1111
+
1112
+ // optionally check for a specific kind of error
1113
+ - if (networkError) {
1114
+ + if (ServerError.is(error)) {
1115
+ // ... handle a server error
1116
+ }
1117
+ });
1118
+ ```
1119
+
1120
+ The `response` property has also been renamed to `result`.
1121
+
1122
+ ```diff
1123
+ createPersistedQueryLink({
1124
+ - disable: ({ response }) => {
1125
+ + disable: ({ result }) => {
1126
+ // ... handle GraphQL errors
1127
+ }
1128
+ }
1129
+ });
1130
+ ```
1131
+
1132
+ - [#12823](https://github.com/apollographql/apollo-client/pull/12823) [`19e315e`](https://github.com/apollographql/apollo-client/commit/19e315e316ae458913f4d11961b0a2a365df0a19) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move all 1st party link types into a namespace.
1133
+
1134
+ - [#12223](https://github.com/apollographql/apollo-client/pull/12223) [`69c1cb6`](https://github.com/apollographql/apollo-client/commit/69c1cb6f831941598987185238a299b050a364bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `subscribeAndCount` testing utility from `@apollo/client/testing`.
1135
+
1136
+ - [#12300](https://github.com/apollographql/apollo-client/pull/12300) [`4d581e4`](https://github.com/apollographql/apollo-client/commit/4d581e4f5a3c5409e5f06a5f164beabdada150f1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Moves all React-related exports to the `@apollo/client/react` entrypoint and out of the main `@apollo/client` entrypoint. This prevents the need to install React in order to use the core client.
1137
+
1138
+ The following is a list of exports available in `@apollo/client` that should now import from `@apollo/client/react`.
1139
+
1140
+ - `ApolloConsumer`
1141
+ - `ApolloProvider`
1142
+ - `createQueryPreloader`
1143
+ - `getApolloContext`
1144
+ - `skipToken`
1145
+ - `useApolloClient`
1146
+ - `useBackgroundQuery`
1147
+ - `useFragment`
1148
+ - `useLazyQuery`
1149
+ - `useLoadableQuery`
1150
+ - `useMutation`
1151
+ - `useQuery`
1152
+ - `useQueryRefHandlers`
1153
+ - `useReactiveVar`
1154
+ - `useReadQuery`
1155
+ - `useSubscription`
1156
+ - `useSuspenseQuery`
1157
+
1158
+ The following is a list of exports available in `@apollo/client/testing` that should now import from `@apollo/client/testing/react`:
1159
+
1160
+ - `MockedProvider`
1161
+
1162
+ - [#12525](https://github.com/apollographql/apollo-client/pull/12525) [`8785186`](https://github.com/apollographql/apollo-client/commit/87851863b94eebbc208671b17aeca73748ac41f6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Throw an error when a client-only query is used in a mocked response passed to `MockLink`.
1163
+
1164
+ - [#12588](https://github.com/apollographql/apollo-client/pull/12588) [`eed825a`](https://github.com/apollographql/apollo-client/commit/eed825a2549f1d21fff2ec179815206b3baf0fcb) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `TContext` generic argument from all types that use it. `TContext` is replaced with `DefaultContext` which can be modified using declaration merging.
1165
+
1166
+ - [#12647](https://github.com/apollographql/apollo-client/pull/12647) [`a70fac6`](https://github.com/apollographql/apollo-client/commit/a70fac6dd8f26b46c813723a7206e55bfb677690) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery`s will now only be registered with the `ApolloClient` while they
1167
+ have subscribers.
1168
+
1169
+ That means that `ApolloClient.getObservableQueries` and `ApolloClient.refetchQueries`
1170
+ will only be able to return/refetch queries that have at least one subscriber.
1171
+
1172
+ This changes the previous meaning of `active` and `inactive` queries:
1173
+
1174
+ - `inactive` queries are queries with a subscriber that are skipped from a
1175
+ React hook or have a `fetchPolicy` of `standby`
1176
+ - `active` queries are queries with at least one subscriber that are not skipped or in `standby`.
1177
+
1178
+ `ObservableQuery`s without subscribers but with an active ongoing network request
1179
+ (e.g. caused by calling `reobserve`) will be handled as if they had a subscriber
1180
+ for the duration of the query.
1181
+
1182
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `transformOperation` and `validateOperation` have been removed and are no longer exported from `@apollo/client/link/utils`. These utilities have been merged into the implementation of `createOperation`. As a result, `createOperation` now returns a well-formed `Operation` object. Previously `createOperation` relied on an external call to `transformOperation` to provide a well-formed `Operation` type. If you use `createOperation` directly, remove the calls to `transformOperation` and `validateOperation` and pass the request directly.
1183
+
1184
+ - [#12428](https://github.com/apollographql/apollo-client/pull/12428) [`abed922`](https://github.com/apollographql/apollo-client/commit/abed92225fd2a5d2a0a2298893a1170df1cd7400) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `urql` multipart subscriptions utilities. Use the native multipart subscriptions support in `urql` instead.
1185
+
1186
+ - [#12590](https://github.com/apollographql/apollo-client/pull/12590) [`a005e82`](https://github.com/apollographql/apollo-client/commit/a005e822de7b24783f85be45df142ffbb9bc561b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Drop `graphql` v15 as a valid peer dependency.
1187
+
1188
+ - [#12678](https://github.com/apollographql/apollo-client/pull/12678) [`91a876b`](https://github.com/apollographql/apollo-client/commit/91a876b059042828e431931e7a3c2e0365c387b8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `queryRef`s created by `preloadQuery` no longer have a `.toPromise()` function. Instead `preloadQuery` now has a `toPromise` function that accepts a queryRef and will resolve when the underlying promise has been resolved.
1189
+
1190
+ ```diff
1191
+ const queryRef = preloadQuery(query, options);
1192
+
1193
+ - await queryRef.toPromise();
1194
+ + await preloadQuery.toPromise(queryRef);
1195
+ ```
1196
+
1197
+ - [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - Reworked the logic for then a loading state is triggered. If the link chain responds synchronously, a loading state will be omitted, otherwise it will be triggered.
1198
+ If local resolvers are used, the time window for "sync vs async" starts as soon as `@exports` variables are resolved.
1199
+
1200
+ - [#12637](https://github.com/apollographql/apollo-client/pull/12637) [`d2a60d4`](https://github.com/apollographql/apollo-client/commit/d2a60d45e734a2518dad2443f85d82553cd6456a) Thanks [@phryneas](https://github.com/phryneas)! - `useQuery`: only advance `previousData` if `data` actually changed
1201
+
1202
+ - [#12478](https://github.com/apollographql/apollo-client/pull/12478) [`5ea6a45`](https://github.com/apollographql/apollo-client/commit/5ea6a45b3ec2f0d526abe78ae03c42bb519f87c7) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `onSubscriptionData` and `onSubscriptionComplete` callbacks from `useSubscription`. Use `onData` and `onComplete` instead.
1203
+
1204
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Switch to [RxJS](https://rxjs.dev/) as the observable implementation. `rxjs` is now a peer dependency of Apollo Client which means you will now need to install `rxjs` in addition to `@apollo/client`.
1205
+
1206
+ This change is mostly transparent, however transforming values on observables, common in link implementations, differs in RxJS vs `zen-observable`. For example, you could modify values in the link chain emitted from a downstream link by using the `.map` function. In RxJS, this is done with the `.pipe` function and passing a `map` operator instead.
1207
+
1208
+ ```ts
1209
+ import { map } from "rxjs";
1210
+
1211
+ const link new ApolloLink((operation, forward) => {
1212
+ return forward(operation).pipe(
1213
+ map((result) => performTransform(result))
1214
+ );
1215
+ });
1216
+ ```
1217
+
1218
+ For a full list of operators and comprehensive documentation on the capabilities of RxJS, check out the [documentation](https://rxjs.dev/).
1219
+
1220
+ - [#12442](https://github.com/apollographql/apollo-client/pull/12442) [`c5ead08`](https://github.com/apollographql/apollo-client/commit/c5ead08d0f10ddd6232b742defe9620533bf41e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `canonizeResults` option. It was prone to memory leaks. As such, some results that were referentially equal when `canonizeResults` option was set to `true` no longer retain the same object identity.
1221
+
1222
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The request handler provided to `ApolloLink` must now return an `Observable`. `null` is no longer supported as a valid return value. If you rely on `null` so that `ApolloLink` provides an empty observable, use the `EMPTY` observable from RxJS instead:
1223
+
1224
+ ```diff
1225
+ import { ApolloLink } from "@apollo/client";
1226
+ + import { EMPTY } from "rxjs";
1227
+
1228
+ const link = new ApolloLink((operation, forward) => {
1229
+ - return null;
1230
+ + return EMPTY;
1231
+ });
1232
+ ```
1233
+
1234
+ If you have a custom link that overrides the `request` method, remove `null` from the return signature:
1235
+
1236
+ ```diff
1237
+ class MyCustomLink extends ApolloLink {
1238
+ request(
1239
+ operation: ApolloLink.Operation,
1240
+ forward: ApolloLink.ForwardFunction,
1241
+ - ): Observable<ApolloLink.Result> | null {
1242
+ + ): Observable<ApolloLink.Result> {
1243
+ // implementation
1244
+ }
1245
+ }
1246
+ ```
1247
+
1248
+ - [#12329](https://github.com/apollographql/apollo-client/pull/12329) [`61febe4`](https://github.com/apollographql/apollo-client/commit/61febe4ef8712a2035d7ac89ea7283138db5229d) Thanks [@phryneas](https://github.com/phryneas)! - Rework package publish format (#12329, #12382)
1249
+
1250
+ We have reworked the way Apollo Client is packaged.
1251
+
1252
+ - shipping ESM and CJS
1253
+ - fixing up source maps
1254
+ - the build targets a modern runtime environment (browserslist query: `"since 2023, node >= 20, not dead"`)
1255
+ - removed the "proxy directory" `package.json` files, e.g. `cache/core/package.json` and `react/package.json`. While these helped with older build tools, modern build tooling uses the `exports` field in the root `package.json` instead and the presence of these files can confuse modern build tooling. If your build tooling still relies on those, please update your imports to import from e.g. `@apollo/client/cache/core/index.js` instead of `@apollo/client/cache/core` - but generally, this should not be necessary.
1256
+ - added an `exports` field to `package.json` to expose entry points
1257
+ - instead of `globalThis.__DEV__`, Apollo Client now primarily relies on the `development` and `production` exports conditions. It falls back to `globalThis.__DEV__` if the bundler doesn't know these, though.
1258
+
1259
+ - [#12566](https://github.com/apollographql/apollo-client/pull/12566) [`ce4b488`](https://github.com/apollographql/apollo-client/commit/ce4b488bef13f2f5ce1b348d8c3196e198165dd6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't `broadcastQueries` when a query is torn down.
1260
+
1261
+ - [#12397](https://github.com/apollographql/apollo-client/pull/12397) [`2545a54`](https://github.com/apollographql/apollo-client/commit/2545a5415b06283be83eb9c4a03a3a8a39b8bcde) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `ObservableQuery.resetQueryStoreErrors` method. This method reset some internal state that was not consumed elsewhere in the client and resulted in a no-op.
1262
+
1263
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `fromPromise` utility function. Use [`from`](https://rxjs.dev/api/index/function/from) instead.
1264
+
1265
+ - [#12388](https://github.com/apollographql/apollo-client/pull/12388) [`0d825be`](https://github.com/apollographql/apollo-client/commit/0d825bef533b41f2e99ef22e620d9f9472825057) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Require environments that support `WeakMap`, `WeakSet` and symbols. Apollo Client would fallback to `Map` and `Set` if the weak versions were not available. This has been removed and expects that these features are available in the source environment.
1266
+
1267
+ If you are running in an environment without `WeakMap`, `WeakSet` or symbols, you will need to find appropriate polyfills.
1268
+
1269
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` no longer supports calling the execute function in render and will now throw. If you need to execute the query immediately, use `useQuery` instead or move the call to a `useEffect`.
1270
+
1271
+ - [#12631](https://github.com/apollographql/apollo-client/pull/12631) [`b147cac`](https://github.com/apollographql/apollo-client/commit/b147cac5c96c44bfc3deb72c12c7521981584c12) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery` will now return a `loading: false` state for `fetchPolicy` `standby`, even before subscription
1272
+
1273
+ - [#12639](https://github.com/apollographql/apollo-client/pull/12639) [`1bdf489`](https://github.com/apollographql/apollo-client/commit/1bdf4893abb173c97877c71012afa15f9d3da8e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `@apollo/client/testing/core` entrypoint in favor of `@apollo/client/testing`.
1274
+
1275
+ - [#12591](https://github.com/apollographql/apollo-client/pull/12591) [`a7e7383`](https://github.com/apollographql/apollo-client/commit/a7e738328951f5dac25a5fe48d28b3640a3e0eb9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Rename the `@apollo/client/link/core` entrypoint to `@apollo/client/link`.
1276
+
1277
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `defaultOptions` and `initialFetchPolicy` options are no longer supported with `useLazyQuery`.
1278
+
1279
+ If you use `defaultOptions`, pass those options directly to the hook instead. If you use `initialFetchPolicy`, use `fetchPolicy` instead.
1280
+
1281
+ - [#12823](https://github.com/apollographql/apollo-client/pull/12823) [`19e315e`](https://github.com/apollographql/apollo-client/commit/19e315e316ae458913f4d11961b0a2a365df0a19) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `OperationBatcher` class is no longer exported from `@apollo/client/link/batch`. It is an implementation detail of `BatchLink` and should not be relied on directly.
1282
+
1283
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `createOperation` no longer accepts `context` as the first argument. Instead make sure `context` is set as the `context` property on the request passed to `createOperation`.
1284
+
1285
+ ```diff
1286
+ createOperation(
1287
+ - startingContext,
1288
+ - { query },
1289
+ + { query, context: startingContext },
1290
+ { client }
1291
+ );
1292
+ ```
1293
+
1294
+ - [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - Dropped the `saveAsLastResult` argument from `ObservableQuery.getCurrentResult`
1295
+
1296
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` no longer supports `variables` in the hook options and therefore no longer performs variable merging. The execute function must now be called with `variables` instead.
1297
+
1298
+ ```ts
1299
+ function MyComponent() {
1300
+ const [execute] = useLazyQuery(query);
1301
+
1302
+ function runExecute() {
1303
+ execute({ variables: { ... }});
1304
+ }
1305
+ }
1306
+ ```
1307
+
1308
+ This change means the execute function returned from `useLazyQuery` is more type-safe. The execute function will require you to pass a `variables` option if the query type includes required variables.
1309
+
1310
+ - [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The resolver function's `context` argument (the 3rd argument) has changed to provide additional information without the possibility of name clashes. Previously the `context` argument would spread request context and override the `client` and `cache` properties to give access to both inside of a resolver. The `context` argument takes now takes the following shape:
1311
+
1312
+ ```ts
1313
+ {
1314
+ // the request context. By default `TContextValue` is of type `DefaultContext`,
1315
+ // but can be changed if a `context` function is provided.
1316
+ requestContext: TContextValue,
1317
+ // The client instance making the request
1318
+ client: ApolloClient,
1319
+ // Whether the resolver is run as a result of gathering exported variables
1320
+ // or resolving the value as part of the result
1321
+ phase: "exports" | "resolve"
1322
+ }
1323
+ ```
1324
+
1325
+ To migrate, pull any request context from `requestContext` and the `cache` from the `client` property:
1326
+
1327
+ ```diff
1328
+ new LocalState({
1329
+ resolvers: {
1330
+ Query: {
1331
+ - myResolver: (parent, args, { someValue, cache }) => {
1332
+ + myResolver: (parent, args, { requestContext, client }) => {
1333
+ + const someValue = requestContext.someValue;
1334
+ + const cache = client.cache;
1335
+ }
1336
+ }
1337
+ }
1338
+ });
1339
+ ```
1340
+
1341
+ - [#12712](https://github.com/apollographql/apollo-client/pull/12712) [`bbb2b61`](https://github.com/apollographql/apollo-client/commit/bbb2b61d259da54560a79813b130a977dae10523) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache-only` queries no longer poll when a `pollInterval` is set. Instead a warning is now emitted that polling has no effect. If the `fetchPolicy` is changed to `cache-only` after polling is already active, polling is stopped.
1342
+
1343
+ - [#12704](https://github.com/apollographql/apollo-client/pull/12704) [`45dba43`](https://github.com/apollographql/apollo-client/commit/45dba43b6ba0c306aad8cfbcfd4029265f5e9106) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `response` property in `onError` link has been renamed to `result`.
1344
+
1345
+ ```diff
1346
+ - onError(({ response }) => {
1347
+ + onError(({ result }) => {
1348
+ // ...
1349
+ });
1350
+ ```
1351
+
1352
+ - [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Apollo Client no longer ships with support for `@client` fields out-of-the-box and now must be opt-in. To opt in to use `@client` fields, pass an instantiated `LocalState` instance to the `localState` option. If a query contains `@client` and local state hasn't been configured, an error will be thrown.
1353
+
1354
+ ```ts
1355
+ import { LocalState } from "@apollo/client/local-state";
1356
+
1357
+ new ApolloClient({
1358
+ localState: new LocalState(),
1359
+ });
1360
+ ```
1361
+
1362
+ - [#12532](https://github.com/apollographql/apollo-client/pull/12532) [`ae0dcad`](https://github.com/apollographql/apollo-client/commit/ae0dcad89924e6b8090ca3182df30e528589b562) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Default the `delay` for all mocked responses passed to `MockLink` using `realisticDelay`. This ensures your test handles loading states by default and is not reliant on a specific timing.
1363
+
1364
+ If you would like to restore the old behavior, use a global default delay of `0`.
1365
+
1366
+ ```ts
1367
+ MockLink.defaultOptions = {
1368
+ delay: 0,
1369
+ };
1370
+ ```
1371
+
1372
+ - [#12442](https://github.com/apollographql/apollo-client/pull/12442) [`c5ead08`](https://github.com/apollographql/apollo-client/commit/c5ead08d0f10ddd6232b742defe9620533bf41e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `resetResultIdentities` option from `InMemoryCache.gc()`. This affected object canonization which has been removed.
1373
+
1374
+ - [#12304](https://github.com/apollographql/apollo-client/pull/12304) [`86469a2`](https://github.com/apollographql/apollo-client/commit/86469a25abb72dbd68adff3554e3909036e77eee) Thanks [@jerelmiller](https://github.com/jerelmiller)! - ### Changes for users of `InMemoryCache`
1375
+
1376
+ `cache.diff` now returns `null` instead of an empty object (`{}`) when `returnPartialData` is `true` and the result is empty.
1377
+
1378
+ If you use `cache.diff` directly with `returnPartialData: true`, you will need to check for `null` before accessing any other fields on the `result` property. A non-null value indicates that at least one field was present in the cache for the given query document.
1379
+
1380
+ ### Changes for third-party cache implementations
1381
+
1382
+ The client now expects `cache.diff` to return `null` instead of an empty object when there is no data that can be fulfilled from the cache and `returnPartialData` is `true`. If your cache implementation returns an empty object, please update this to return `null`.
1383
+
1384
+ - [#12433](https://github.com/apollographql/apollo-client/pull/12433) [`b86e50b`](https://github.com/apollographql/apollo-client/commit/b86e50b1dc121cd67fe73655256b6c61afc18cb4) Thanks [@phryneas](https://github.com/phryneas)! - Remove workarounds for streaming with non-WhatWG response bodies to reduce bundle size.
1385
+
1386
+ This removes support for `fetch` implementations that return Node Streams, Async Iterators or Blob instances as `Response.body`.
1387
+
1388
+ In the WhatWG Fetch specification, [`Response.body`](https://fetch.spec.whatwg.org/#body) is specified as a WhatWG [ReadableStream](https://streams.spec.whatwg.org/#readablestream).
1389
+
1390
+ At this point in time, this is natively supported in browsers, `node` and React Native (via [react-native-fetch-api](https://www.npmjs.com/package/react-native-fetch-api), see our [setup instructions for React Native](https://www.apollographql.com/docs/react/integrations/react-native#consuming-multipart-http-via-text-streaming)).
1391
+
1392
+ If you are using an older `fetch` polyfill that deviates from the spec, this might not be compatible - for example, [node-fetch](https://github.com/node-fetch/node-fetch?tab=readme-ov-file#interface-body) returns a node `Readable` instead of a `ReadableStream`.
1393
+ In those cases, please switch to a compatible alternative such as the `node`-native `fetch`, or `undici`.
1394
+
1395
+ - [#12484](https://github.com/apollographql/apollo-client/pull/12484) [`9a8b9ce`](https://github.com/apollographql/apollo-client/commit/9a8b9cebbcf290984a4f154f261a4090e636e50e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `loading`, `networkStatus`, and `partial` properties on all promise-based query APIs. These properties were mostly static and were unnecessary since promise resolution guaranteed that the query was not longer loading.
1396
+
1397
+ This affects the following APIs:
1398
+
1399
+ - `client.query`
1400
+ - `client.refetchQueries`
1401
+ - `client.reFetchObservableQueries`
1402
+ - `client.resetStore`
1403
+ - `observableQuery.fetchMore`
1404
+ - `observableQuery.refetch`
1405
+ - `observableQuery.reobserve`
1406
+ - `observableQuery.setVariables`
1407
+ - The `useLazyQuery` `execute` function
1408
+
1409
+ - [#12512](https://github.com/apollographql/apollo-client/pull/12512) [`e809b71`](https://github.com/apollographql/apollo-client/commit/e809b71aa9a02917a286afdbb03d5be8e5947c53) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `notifyOnNetworkStatusChange` now defaults to `true`. This means that loading states will be emitted (core API) or rendered (React) by default when calling `refetch`, `fetchMore`, etc. To maintain the old behavior, set `notifyOnNetworkStatusChange` to `false` in `defaultOptions`.
1410
+
1411
+ ```ts
1412
+ new ApolloClient({
1413
+ defaultOptions: {
1414
+ watchQuery: {
1415
+ // Use the v3 default
1416
+ notifyOnNetworkStatusChange: false,
1417
+ },
1418
+ },
1419
+ });
1420
+ ```
1421
+
1422
+ - [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `fragmentMatcher` option from `ApolloClient`. Custom fragment matchers used with local state are no longer supported. Fragment matching is now performed by the configured `cache` via the `cache.fragmentMatches` API.
1423
+
1424
+ - [#12430](https://github.com/apollographql/apollo-client/pull/12430) [`2ff66d0`](https://github.com/apollographql/apollo-client/commit/2ff66d06b6d444fbcb46e580ac40e673e695740f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes `ObservableQuery.result()` method. If you use this method and need similar functionality, use the `firstValueFrom` helper in RxJS.
1425
+
1426
+ ```ts
1427
+ import { firstValueFrom, from } from "rxjs";
1428
+
1429
+ // The `from` is necessary to turn `observableQuery` into an RxJS observable
1430
+ const result = await firstValueFrom(from(observableQuery));
1431
+ ```
1432
+
1433
+ - [#12359](https://github.com/apollographql/apollo-client/pull/12359) [`ebb4d96`](https://github.com/apollographql/apollo-client/commit/ebb4d9644104244fb066b93a32df778928f2f8a9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `onCompleted` and `onError` callbacks from `useQuery` and `useLazyQuery`.
1434
+
1435
+ See [#12352](https://github.com/apollographql/apollo-client/issues/12352) for more context on this change.
1436
+
1437
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Subscriptions are no longer eagerly started after calling `client.subscribe`. To kick off the subscription, you will now need to subscribe to the returned observable.
1438
+
1439
+ ```ts
1440
+ // Subscriptions are no longer started when calling subscribe on its own.
1441
+ const subscriptionObservable = client.subscribe(...);
1442
+
1443
+ // Instead, subscribe to the returned observable to kick off the subscription.
1444
+ subscriptionObservable.subscribe({
1445
+ next: (value) => console.log(value)
1446
+ });
1447
+ ```
1448
+
1449
+ - [#12476](https://github.com/apollographql/apollo-client/pull/12476) [`6afff60`](https://github.com/apollographql/apollo-client/commit/6afff60beece953406af2cbe07f7ccbf973cadaa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - GraphQL errors or network errors emitted while using an `errorPolicy` of `ignore` in subscriptions will no longer emit a result if there is no `data` emitted along with the error.
1450
+
1451
+ - [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` will now only execute the query when the execute function is called. Previously `useLazyQuery` would behave like `useQuery` after the first call to the execute function which means changes to options might perform network requests.
1452
+
1453
+ You can now safely rerender `useLazyQuery` with new options which will take effect the next time you manually trigger the query.
1454
+
1455
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `TVariables` generic argument on the `GraphQLRequest` type.
1456
+
1457
+ - [#12464](https://github.com/apollographql/apollo-client/pull/12464) [`0595f39`](https://github.com/apollographql/apollo-client/commit/0595f39deba52ac43fa0780b742564134ec7ab89) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `called` property from `useQuery`.
1458
+
1459
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `toPromise` utility function. Use [`firstValueFrom`](https://rxjs.dev/api/index/function/firstValueFrom) instead.
1460
+
1461
+ - [#12476](https://github.com/apollographql/apollo-client/pull/12476) [`6afff60`](https://github.com/apollographql/apollo-client/commit/6afff60beece953406af2cbe07f7ccbf973cadaa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Subscriptions no longer emit errors in the `error` callback and instead provide errors on the `error` property on the result passed to the `next` callback. As a result, errors will no longer automatically terminate the connection allowing additional results to be emitted when the connection stays open.
1462
+
1463
+ When an error terminates the downstream connection, a `next` event will be emitted with an `error` property followed by a `complete` event instead.
1464
+
1465
+ - [#12841](https://github.com/apollographql/apollo-client/pull/12841) [`65b503f`](https://github.com/apollographql/apollo-client/commit/65b503fe4bfcf942e8f66f36f622f5f6448d6731) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `DataMasking` interface exported from `@apollo/client` and `@apollo/client/masking`.
1466
+
1467
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The context object returned from `operation.getContext()` is now frozen to prevent mutable changes to the object which could result in subtle bugs. This applies to the `previousContext` object passed to the `operation.setContext()` callback as well.
1468
+
1469
+ - [#12715](https://github.com/apollographql/apollo-client/pull/12715) [`0be0b3f`](https://github.com/apollographql/apollo-client/commit/0be0b3f54a1b533c95c69d3698c5c3bdbd6279fe) Thanks [@phryneas](https://github.com/phryneas)! - All links are now available as classes. The old creator functions have been deprecated.
1470
+
1471
+ Please migrate these function calls to class creations:
1472
+
1473
+ ```diff
1474
+ import {
1475
+ - setContext
1476
+ + SetContextLink
1477
+ } from "@apollo/client/link/context"
1478
+
1479
+ -const link = setContext(...)
1480
+ +const link = new SetContextLink(...)
1481
+ ```
1482
+
1483
+ ```diff
1484
+ import {
1485
+ - createHttpLink
1486
+ + HttpLink
1487
+ } from "@apollo/client/link/http"
1488
+
1489
+ -const link = createHttpLink(...)
1490
+ +const link = new HttpLink(...)
1491
+ ```
1492
+
1493
+ ```diff
1494
+ import {
1495
+ - createPersistedQueryLink
1496
+ + PersistedQueryLink
1497
+ } from "@apollo/client/link/persisted-queries"
1498
+
1499
+ -const link = createPersistedQueryLink(...)
1500
+ +const link = new PersistedQueryLink(...)
1501
+ ```
1502
+
1503
+ ```diff
1504
+ import {
1505
+ - removeTypenameFromVariables
1506
+ + RemoveTypenameFromVariablesLink
1507
+ } from "@apollo/client/link/remove-typename"
1508
+
1509
+ -const link = removeTypenameFromVariables(...)
1510
+ +const link = new RemoveTypenameFromVariablesLink(...)
1511
+ ```
1512
+
1513
+ - [#12530](https://github.com/apollographql/apollo-client/pull/12530) [`2973e2a`](https://github.com/apollographql/apollo-client/commit/2973e2a6e6fd81fa59b769d84c252c98ca69440d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `newData` option for mocked responses passed to `MockLink` or the `mocks` option on `MockedProvider`. This option was undocumented and was nearly identical to using the `result` option as a callback.
1514
+
1515
+ To replicate the old behavior of `newData`, use `result` as a callback and add the `maxUsageCount` option with a value set to `Number.POSITIVE_INFINITY`.
1516
+
1517
+ **with `MockLink`**
1518
+
1519
+ ```diff
1520
+ new MockLink([
1521
+ {
1522
+ request: { query, variables },
1523
+ - newData: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
1524
+ + result: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
1525
+ + maxUsageCount: Number.POSITIVE_INFINITY,
1526
+ }
1527
+ ])
1528
+ ```
1529
+
1530
+ **with `MockedProvider`**
1531
+
1532
+ ```diff
1533
+ <MockedProvider
1534
+ mocks={[
1535
+ {
1536
+ request: { query, variables },
1537
+ - newData: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
1538
+ + result: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
1539
+ + maxUsageCount: Number.POSITIVE_INFINITY,
1540
+ }
1541
+ ]}
1542
+ />
1543
+ ```
1544
+
1545
+ - [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - A call to `ObservableQuery.setVariables` with different variables or a `ObservableQuery.refetch` call will always now guarantee that a value will be emitted from the observable, even if it is deep equal to the previous value.
1546
+
1547
+ - [#12647](https://github.com/apollographql/apollo-client/pull/12647) [`a70fac6`](https://github.com/apollographql/apollo-client/commit/a70fac6dd8f26b46c813723a7206e55bfb677690) Thanks [@phryneas](https://github.com/phryneas)! - `ApolloClient.stop()` now cleans up more agressively to prevent memory leaks:
1548
+
1549
+ - It will now unsubscribe all active `ObservableQuery` instances by emitting a `completed` event.
1550
+ - It will now reject all currently running queries with `"QueryManager stopped while query was in flight"`.
1551
+ - It will remove all queryRefs from the suspense cache.
1552
+
1553
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `forward` function passed to the request handler is now always provided to `request` and no longer optional. If you create custom links by subclassing `ApolloLink`, the `forward` function no longer needs to be optional:
1554
+
1555
+ ```ts
1556
+ class CustomLink extends ApolloLink {
1557
+ request(
1558
+ operation: ApolloLink.Operation,
1559
+ // This no longer needs to be typed as optional
1560
+ forward: ApolloLink.ForwardFunction
1561
+ ) {
1562
+ // ...
1563
+ }
1564
+ }
1565
+ ```
1566
+
1567
+ As a result of this change, `ApolloLink` no longer detects terminating links by checking function arity on the request handler. This means using methods such as `concat` on a terminating link no longer emit a warning. On the flip side, if the terminating link calls the `forward` function, a warning is emitted and an observable that immediately completes is returned which will result in an error from Apollo Client.
1568
+
1569
+ - [#12589](https://github.com/apollographql/apollo-client/pull/12589) [`15f5a1c`](https://github.com/apollographql/apollo-client/commit/15f5a1c29ac05015387a7bbc2dbe9a91d09fedfa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Require the `link` option when instantiating `ApolloClient`. This removes the `uri`, `credentials` and `headers` options from `ApolloClient` in favor of passing an instantiated `HttpLink` directly. To migrate:
1570
+
1571
+ **If using `uri`, `credentials`, or `headers` options**
1572
+
1573
+ ```diff
1574
+ new ApolloClient({
1575
+ // ...
1576
+ - uri,
1577
+ - credentials,
1578
+ - headers,
1579
+ + link: new HttpLink({ uri, credentials, headers }),
1580
+ // or if you prefer the function call approach:
1581
+ + link: createHttpLink({ uri, credentials, headers }),
1582
+ });
1583
+ ```
1584
+
1585
+ **If creating a client without the `link` option**
1586
+
1587
+ ```diff
1588
+ new ApolloClient({
1589
+ // ...
1590
+ + link: ApolloLink.empty()
1591
+ });
1592
+ ```
1593
+
1594
+ - [#12304](https://github.com/apollographql/apollo-client/pull/12304) [`86469a2`](https://github.com/apollographql/apollo-client/commit/86469a25abb72dbd68adff3554e3909036e77eee) Thanks [@jerelmiller](https://github.com/jerelmiller)! - ### Changes for users of `InMemoryCache`
1595
+
1596
+ `cache.diff` no longer throws when `returnPartialData` is set to `false` without a complete result. Instead, `cache.diff` will return `null` when it is unable to read a full cache result.
1597
+
1598
+ If you use `cache.diff` directly with `returnPartialData: false`, remove the `try`/`catch` block and replace with a check for `null`.
1599
+
1600
+ ### Changes for third-party cache implementations
1601
+
1602
+ The client now expects `cache.diff` to return `null` instead of throwing when the cache returns an incomplete result and `returnPartialData` is `false`. The internal `try`/`catch` blocks have been removed around `cache.diff`. If your cache implementation throws for incomplete results, please update this to return `null`.
1603
+
1604
+ - [#12451](https://github.com/apollographql/apollo-client/pull/12451) [`77e1b13`](https://github.com/apollographql/apollo-client/commit/77e1b133bdba32c67b5a840090dbacb16282dee9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Default the `TData` generic type to `unknown` in all APIs that use a `TData` generic argument such as `useQuery`, `client.query`, etc.
1605
+
1606
+ - [#12562](https://github.com/apollographql/apollo-client/pull/12562) [`90bf0e6`](https://github.com/apollographql/apollo-client/commit/90bf0e61516a382182f212ac8ab891099e2eb009) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `client.query` no longer supports a `fetchPolicy` of `standby`. `standby` does not fetch and did not return `data`. `standby` is meant for watched queries where fetching should be on hold.
1607
+
1608
+ - [#12211](https://github.com/apollographql/apollo-client/pull/12211) [`c2736db`](https://github.com/apollographql/apollo-client/commit/c2736db3ad6f8b6e56f065682d5b76614f41bfd4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `Query`, `Mutation`, and `Subscription` components. Use the provided React hooks instead.
1609
+
1610
+ </details>
1611
+
1612
+ <details>
1613
+
1614
+ <summary>
1615
+
1616
+ ### Minor Changes
1617
+
1618
+ </summary>
1619
+
1620
+ - [#12532](https://github.com/apollographql/apollo-client/pull/12532) [`ae0dcad`](https://github.com/apollographql/apollo-client/commit/ae0dcad89924e6b8090ca3182df30e528589b562) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Allow mocked responses passed to `MockLink` to accept a callback for the `delay` option. The `delay` callback will be given the current operation which can be used to determine what delay should be used for the mock.
1621
+
1622
+ - [#12711](https://github.com/apollographql/apollo-client/pull/12711) [`f730f83`](https://github.com/apollographql/apollo-client/commit/f730f83346d4e3c20116da6f55fdd1381114416c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add an `extensions` property to `CombinedGraphQLErrors` to capture any extensions from the original response.
1623
+
1624
+ - [#12438](https://github.com/apollographql/apollo-client/pull/12438) [`5089516`](https://github.com/apollographql/apollo-client/commit/5089516aa3ad140df22bb8a458faeeb884ed0388) Thanks [@phryneas](https://github.com/phryneas)! - Drop `rehackt` dependency.
1625
+ We can now directly import from `react` without causing build errors in RSC.
1626
+
1627
+ - [#12437](https://github.com/apollographql/apollo-client/pull/12437) [`4779dc7`](https://github.com/apollographql/apollo-client/commit/4779dc7badaba10d8c7a271eb0da6a079049b65d) Thanks [@phryneas](https://github.com/phryneas)! - Remove polyfills for Object.freeze,seal and preventExtensions in React Native
1628
+
1629
+ These polyfills were only necessary until React Native 0.59, which
1630
+ [patched the problem](https://github.com/facebook/react-native/pull/21492) on
1631
+ the React Native side.
1632
+
1633
+ With React Native 0.61, the `Map` function was [completely replaced](https://github.com/facebook/react-native/commit/93b9ac74e59bbe84ea388d7c1879857b4acab114)
1634
+ with a native implementation that never had the problems we guarded against.
1635
+
1636
+ - [#12557](https://github.com/apollographql/apollo-client/pull/12557) [`51d26ae`](https://github.com/apollographql/apollo-client/commit/51d26ae631c6631a189c98ea9357b18e77a9a876) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add ability to specify message formatter for `CombinedGraphQLErrors` and `CombinedProtocolErrors`. To provide your own message formatter, override the static `formatMessage` property on these classes.
1637
+
1638
+ ```ts
1639
+ CombinedGraphQLErrors.formatMessage = (
1640
+ errors,
1641
+ { result, defaultFormatMessage }
1642
+ ) => {
1643
+ return "Some formatted message";
1644
+ };
1645
+
1646
+ CombinedProtocolErrors.formatMessage = (errors, { defaultFormatMessage }) => {
1647
+ return "Some formatted message";
1648
+ };
1649
+ ```
1650
+
1651
+ - [#12776](https://github.com/apollographql/apollo-client/pull/12776) [`bce9b74`](https://github.com/apollographql/apollo-client/commit/bce9b7448a226b109cbe8f14911503fb09f37825) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `dataState` to the value emitted from `client.watchFragment`.
1652
+
1653
+ - [#12670](https://github.com/apollographql/apollo-client/pull/12670) [`0a880ea`](https://github.com/apollographql/apollo-client/commit/0a880ea4c2360a985fdd2edadb94fcc4b82bad73) Thanks [@phryneas](https://github.com/phryneas)! - Provide a mechanism to override the DataMasking types.
1654
+
1655
+ Up until now, our types `Masked`, `MaskedDocumentNode`, `FragmentType`, `MaybeMasked` and `Unmasked` would assume that you are stictly using the type output format of GraphQL Codegen.
1656
+
1657
+ With this change, you can now modify the behaviour of those types if you use a different form of codegen that produces different types for your queries.
1658
+
1659
+ A simple implementation that would override the `Masked` type to remove all fields starting with `_` from a type would look like this:
1660
+
1661
+ ```ts
1662
+ // your actual implementation of `Masked`
1663
+ type CustomMaskedImplementation<TData> = {
1664
+ [K in keyof TData as K extends `_${string}` ? never : K]: TData[K];
1665
+ };
1666
+
1667
+ import { HKT } from "@apollo/client/utilities";
1668
+ // transform this type into a higher kinded type that can be evaulated at a later time
1669
+ interface CustomMaskedType extends HKT {
1670
+ arg1: unknown; // TData
1671
+ return: CustomMaskedImplementation<this["arg1"]>;
1672
+ }
1673
+
1674
+ // create an "implementation interface" for the types you want to override
1675
+ export interface CustomDataMaskingImplementation {
1676
+ Masked: CustomMaskedType;
1677
+ // other possible keys: `MaskedDocumentNode`, `FragmentType`, `MaybeMasked` and `Unmasked`
1678
+ }
1679
+ ```
1680
+
1681
+ then you would use that `CustomDataMaskingImplementation` interface in your project to extend the `TypeOverrides` interface exported by `@apollo/client` with it's functionality:
1682
+
1683
+ ```ts
1684
+ declare module "@apollo/client" {
1685
+ export interface TypeOverrides extends CustomDataMaskingImplementation {}
1686
+ }
1687
+ ```
1688
+
1689
+ After that, all internal usage of `Masked` in Apollo Client as well as all usage in your code base will use the new `CustomMaskedType` implementation.
1690
+
1691
+ If you don't specify overrides, Apollo Client will still default to the GraphQL Codegen data masking implementation.
1692
+ The types for that are also explicitly exported as the `GraphQLCodegenDataMasking` namespace in `@apollo/client/masking`.
1693
+
1694
+ - [#12532](https://github.com/apollographql/apollo-client/pull/12532) [`ae0dcad`](https://github.com/apollographql/apollo-client/commit/ae0dcad89924e6b8090ca3182df30e528589b562) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Introduce a new `realisticDelay` helper function for use with the `delay` callback for mocked responses used with `MockLink`. `realisticDelay` will generate a random value between 20 and 50ms to provide an experience closer to unpredictable network latency. `realisticDelay` can be configured with a `min` and `max` to set different thresholds if the defaults are not sufficient.
1695
+
1696
+ ```ts
1697
+ import { realisticDelay } from "@apollo/client/testing";
1698
+
1699
+ new MockLink([
1700
+ {
1701
+ request: { query },
1702
+ result: { data: { greeting: "Hello" } },
1703
+ delay: realisticDelay(),
1704
+ },
1705
+ {
1706
+ request: { query },
1707
+ result: { data: { greeting: "Hello" } },
1708
+ delay: realisticDelay({ min: 10, max: 100 }),
1709
+ },
1710
+ ]);
1711
+ ```
1712
+
1713
+ - [#12844](https://github.com/apollographql/apollo-client/pull/12844) [`18a0cad`](https://github.com/apollographql/apollo-client/commit/18a0cad773257e540ec8dc8e90f7a875a0ccf99f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add an entrypoint at `@apollo/client/v4-migration` that includes removed values and types. Each export includes doc blocks on how to migrate away from the removed type.
1714
+
1715
+ - [#12546](https://github.com/apollographql/apollo-client/pull/12546) [`5dffbbe`](https://github.com/apollographql/apollo-client/commit/5dffbbe407eb1d9adbcb0fff89f2d3a75dc1ad2b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a static `is` method to error types defined by Apollo Client. `is` makes it simpler to determine whether an error is a specific type, which can be helpful in cases where you'd like to narrow the error type in order to use specific properties from that error.
1716
+
1717
+ This change applies to the following error types:
1718
+
1719
+ - `CombinedGraphQLErrors`
1720
+ - `CombinedProtocolErrors`
1721
+ - `ServerError`
1722
+ - `ServerParseError`
1723
+ - `UnconventionalError`
1724
+
1725
+ **Example**
1726
+
1727
+ ```ts
1728
+ import { CombinedGraphQLErrors } from "@apollo/client";
1729
+
1730
+ if (CombinedGraphQLErrors.is(error)) {
1731
+ console.log(error.message);
1732
+ error.errors.forEach((graphQLError) => console.log(graphQLError.message));
1733
+ }
1734
+ ```
1735
+
1736
+ - [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Revamp local resolvers and fix several issues from the existing `resolvers` option.
1737
+
1738
+ - Throwing errors in a resolver will set the field value as `null` and add an error to the response's `errors` array.
1739
+ - Remote results are dealiased before they are passed as the parent object to a resolver so that you can access fields by their field name.
1740
+ - You can now specify a `context` function that you can use to customize the `requestContext` given to resolvers.
1741
+ - The `LocalState` class accepts a `Resolvers` generic that provides autocompletion and type checking against your resolver types to ensure your resolvers are type-safe.
1742
+ - `data: null` is now handled correctly and does not call your local resolvers when the server does not provide a result.
1743
+ - Additional warnings have been added to provide hints when resolvers behave unexpectedly.
1744
+
1745
+ ```ts
1746
+ import { LocalState } from "@apollo/client/local-state";
1747
+
1748
+ import { Resolvers } from "./path/to/local-resolvers-types.ts";
1749
+
1750
+ // LocalState now accepts a `Resolvers` generic.
1751
+ const localState = new LocalState<Resolvers>({
1752
+ // The return value of this funciton
1753
+ context: (options) => ({
1754
+ // ...
1755
+ }),
1756
+ resolvers: {
1757
+ // ...
1758
+ },
1759
+ });
1760
+
1761
+ // You may also pass a `ContextValue` generic used to ensure the `context`
1762
+ // function returns the correct type. This type is inferred from your resolvers
1763
+ // if not provided.
1764
+ new LocalState<Resolvers, ContextValue>({
1765
+ // ...
1766
+ });
1767
+ ```
1768
+
1769
+ - [#12828](https://github.com/apollographql/apollo-client/pull/12828) [`81b03d8`](https://github.com/apollographql/apollo-client/commit/81b03d86ad7e7384124708477829bcbf63d4fa2c) Thanks [@phryneas](https://github.com/phryneas)! - `invariant.error` will now also log in production builds, not only dev builds
1770
+
1771
+ - [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - The callback function that can be passed to the `ApolloClient.mutate`
1772
+ `refetchQueries` option will now receive a `FormattedExecutionResult` with an
1773
+ additional `dataState` option that describes if the result is `"streaming"`
1774
+ or `"complete"`.
1775
+ This indicates whether the `data` value is of type
1776
+
1777
+ - `Unmasked<TData>` (if `"complete"`)
1778
+ - `Streaming<Unmasked<TData>>` (if `"streaming"`)
1779
+
1780
+ - [#12385](https://github.com/apollographql/apollo-client/pull/12385) [`cad5117`](https://github.com/apollographql/apollo-client/commit/cad511723a1b8b0ac2042cf49435f7affb0dc4e4) Thanks [@phryneas](https://github.com/phryneas)! - Apollo Client is no longer using `ts-invariant`, but ships with a modified variant of it.
1781
+
1782
+ The existing export `setLogVerbosity` from `@apollo/client` is still available and
1783
+ now points to this new integration.
1784
+ **In most cases, you should be using this export.**
1785
+ It will no longer adjust the verbosity of `ts-invariant` and as such no longer
1786
+ influence other packages relying on `ts-invariant`.
1787
+
1788
+ The new entry point `@apollo/client/utilities/invariant` now exports `invariant`,
1789
+ `InvariantError` and `setVerbosity`.
1790
+ (Note that these tools are mostly meant to be used by Apollo Client and libraries directly
1791
+ based on Apollo Client like the `@apollo/client-integration-*` packages.)
1792
+
1793
+ - [#12576](https://github.com/apollographql/apollo-client/pull/12576) [`a92ff78`](https://github.com/apollographql/apollo-client/commit/a92ff780abee60896bb9632867e90c82d0829255) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Provide an extension to define types for `context` passed to the link chain. To define your own types, use [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) to add properties to the `DefaultContext` type.
1794
+
1795
+ ```ts
1796
+ // @apollo-client.d.ts
1797
+ // This import is necessary to ensure all Apollo Client imports
1798
+ // are still available to the rest of the application.
1799
+ import "@apollo/client";
1800
+
1801
+ declare module "@apollo/client" {
1802
+ interface DefaultContext extends Record<string, any> {
1803
+ myProperty: string;
1804
+ }
1805
+ }
1806
+ ```
1807
+
1808
+ Links that provide context options can be used with this type to add those context types to `DefaultContext`. For example, to add context options from `HttpLink`, add the following code:
1809
+
1810
+ ```ts
1811
+ import { HttpLink } from "@apollo/client";
1812
+
1813
+ declare module "@apollo/client" {
1814
+ interface DefaultContext extends HttpLink.ContextOptions {
1815
+ myProperty: string;
1816
+ }
1817
+ }
1818
+ ```
1819
+
1820
+ At this time, the following built-in links support context options:
1821
+
1822
+ - `HttpLink.ContextOptions`
1823
+ - `BatchHttpLink.ContextOptions`
1824
+
1825
+ - [#12714](https://github.com/apollographql/apollo-client/pull/12714) [`0e39469`](https://github.com/apollographql/apollo-client/commit/0e394692eaf0f8d8e506d8304935deafa952accf) Thanks [@phryneas](https://github.com/phryneas)! - Allow passing `errorPolicy` option to `fetchMore` and change default value to "none".
1826
+
1827
+ - [#12497](https://github.com/apollographql/apollo-client/pull/12497) [`ff2cbe1`](https://github.com/apollographql/apollo-client/commit/ff2cbe1db1815c30f5fda7f6c07091663e065582) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a `data` property to `CombinedGraphQLErrors` that captures any partial data returned by the GraphQL response when `errors` are also returned.
1828
+
1829
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ApolloLink`'s `concat` method now accepts multiple links to concatenate together.
1830
+
1831
+ ```ts
1832
+ const first = new ApolloLink();
1833
+
1834
+ const link = first.concat(second, third, fouth);
1835
+ ```
1836
+
1837
+ - [#12753](https://github.com/apollographql/apollo-client/pull/12753) [`b85818d`](https://github.com/apollographql/apollo-client/commit/b85818dcc66d3ed8b1c3a7e5e37b2875d6bf9d03) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Renamed `client.reFetchObservableQueries` to `client.refetchObservableQueries`.
1838
+ `client.reFetchObservableQueries` is still available as an alias, but is now
1839
+ deprecated and will be removed in a future major version.
1840
+
1841
+ - [#12561](https://github.com/apollographql/apollo-client/pull/12561) [`99d72bf`](https://github.com/apollographql/apollo-client/commit/99d72bfdb38e3d9679f60b9acb065a84e3b42fd6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the ability to detect if an error was an error was emitted from the link chain. This is useful if your application throws custom errors in other areas of the application and you'd like to differentiate them from errors emitted by the link chain itself.
1842
+
1843
+ To detect if an error was emitted from the link chain, use `LinkError.is`.
1844
+
1845
+ ```ts
1846
+ import { LinkError } from "@apollo/client";
1847
+
1848
+ client.query({ query }).catch((error) => {
1849
+ if (LinkError.is(error)) {
1850
+ // This error originated from the link chain
1851
+ }
1852
+ });
1853
+ ```
1854
+
1855
+ - [#12698](https://github.com/apollographql/apollo-client/pull/12698) [`be77d1a`](https://github.com/apollographql/apollo-client/commit/be77d1a6ddf719cab4780a0679fcd98556ac7f22) Thanks [@phryneas](https://github.com/phryneas)! - Adjusted the accept header for multipart requests according to the new GraphQL over HTTP spec with these changes:
1856
+
1857
+ ```diff
1858
+ -multipart/mixed;boundary=graphql;subscriptionSpec=1.0,application/json
1859
+ +multipart/mixed;boundary=graphql;subscriptionSpec=1.0,application/graphql-response+json,application/json;q=0.9
1860
+ ```
1861
+
1862
+ ```diff
1863
+ -multipart/mixed;deferSpec=20220824,application/json
1864
+ +multipart/mixed;deferSpec=20220824,application/graphql-response+json,application/json;q=0.9
1865
+ ```
1866
+
1867
+ - [#12663](https://github.com/apollographql/apollo-client/pull/12663) [`01512f2`](https://github.com/apollographql/apollo-client/commit/01512f2429dd394fb72b8ba9284047a09ade666f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Subscriptions created by `client.subscribe()` can now be restarted. Restarting a subscription will terminate the connection with the link chain and recreate the request. Restarts also work across deduplicated subscriptions so calling `restart` on an `observable` who's request is deduplicated will restart the connection for each observable.
1868
+
1869
+ ```ts
1870
+ const observable = client.subscribe({ query: subscription });
1871
+
1872
+ // Restart the connection to the link
1873
+ observable.restart();
1874
+ ```
1875
+
1876
+ - [#12639](https://github.com/apollographql/apollo-client/pull/12639) [`1bdf489`](https://github.com/apollographql/apollo-client/commit/1bdf4893abb173c97877c71012afa15f9d3da8e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move `MockLink` types to `MockLink` namespace. This affects the `MockedResponse`, `MockLinkOptions`, and `ResultFunction` types. These types are still exported but are deprecated in favor of the namespace. To migrate, use the types on the `MockLink` namespace instead.
1877
+
1878
+ ```diff
1879
+ import {
1880
+ - MockedResponse,
1881
+ - MockLinkOptions,
1882
+ - ResultFunction,
1883
+ + MockLink
1884
+ } from "@apollo/client/testing";
1885
+
1886
+ - const mocks: MockedResponse = [];
1887
+ + const mocks: MockLink.MockedResponse = [];
1888
+
1889
+ - const result: ResultFunction = () => {/* ... */ }
1890
+ + const result: MockLink.ResultFunction = () => {/* ... */ }
1891
+
1892
+ - const options: MockLinkOptions = {}
1893
+ + const options: MockLink.Options = {}
1894
+ ```
1895
+
1896
+ - [#12201](https://github.com/apollographql/apollo-client/pull/12201) [`1c6e03c`](https://github.com/apollographql/apollo-client/commit/1c6e03c9c74a9fad2a1c2e1c3ae61a9560038238) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Overridable types for `dataState: "complete"`, `dataState: "streaming"` and
1897
+ `dataState: "partial"` responses.
1898
+
1899
+ This adds the `DataValue` namespace exported from Apollo Client with the three
1900
+ types `DataValue.Complete`, `DataValue.Streaming` and `DataValue.Partial`.
1901
+
1902
+ These types will be used to mark `TData` in the respective states.
1903
+
1904
+ - `Complete` defaults to `TData`
1905
+ - `Streaming` defaults to `TData`
1906
+ - `Partial` defaults to `DeepPartial<TData>`
1907
+
1908
+ All three can be overwritten, e.g. to be `DeepReadonly` using higher kinded types
1909
+ by following this pattern:
1910
+
1911
+ ```ts
1912
+ import { HKT, DeepPartial } from "@apollo/client/utilities";
1913
+ import { DeepReadonly } from "some-type-helper-library";
1914
+
1915
+ interface CompleteOverride extends HKT {
1916
+ return: DeepReadonly<this["arg1"]>;
1917
+ }
1918
+
1919
+ interface StreamingOverride extends HKT {
1920
+ return: DeepReadonly<this["arg1"]>;
1921
+ }
1922
+
1923
+ interface PartialOverride extends HKT {
1924
+ return: DeepReadonly<DeepPartial<this["arg1"]>>;
1925
+ }
1926
+
1927
+ declare module "@apollo/client" {
1928
+ export interface TypeOverrides {
1929
+ Complete: CompleteOverride;
1930
+ Streaming: StreamingOverride;
1931
+ Partial: PartialOverride;
1932
+ }
1933
+ }
1934
+ ```
1935
+
1936
+ - [#12663](https://github.com/apollographql/apollo-client/pull/12663) [`01512f2`](https://github.com/apollographql/apollo-client/commit/01512f2429dd394fb72b8ba9284047a09ade666f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Deduplicating subscription operations is now supported. Previously it was possible to deduplicate a subscription only if the new subscription was created before a previously subscribed subscription emitted any values. As soon as a value was emitted from a subscription, new subscriptions would create new connections. Deduplication is now active for as long as a subscription connection is open (i.e. the source observable hasn't emitted a `complete` or `error` notification yet.)
1937
+
1938
+ To disable deduplication and force a new connection, use the `queryDeduplication` option in `context` like you would a query operation.
1939
+
1940
+ As a result of this change, calling the `restart` function returned from `useSubscription` will now restart the connection on deduplicated subscriptions.
1941
+
1942
+ - [#12438](https://github.com/apollographql/apollo-client/pull/12438) [`5089516`](https://github.com/apollographql/apollo-client/commit/5089516aa3ad140df22bb8a458faeeb884ed0388) Thanks [@phryneas](https://github.com/phryneas)! - Add `react-server` entry point with stubs for normal exports.
1943
+
1944
+ - [#12333](https://github.com/apollographql/apollo-client/pull/12333) [`3e4beaa`](https://github.com/apollographql/apollo-client/commit/3e4beaa8b768a893da80aae0428f79ee01d6aa38) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Deprecate the `partial` flag on `ApolloQueryResult` and make it a non-optional property. Previously `partial` was only set conditionally if the result emitted was partial. This value is now available with all results that return an `ApolloQueryResult`.
1945
+
1946
+ - [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - Add the new `ClientAwarenessLink`.
1947
+
1948
+ This link is already included in `HttpLink` and `BatchHttpLink` to enable the
1949
+ "client awareness" and "enhanced client awareness" features, but you can also use
1950
+ `ClientAwarenessLink` directly in your link chain to combine it with other
1951
+ terminating links.
1952
+
1953
+ If you want to save the bundle size that `ClientAwarenessLink` adds to `HttpLink`
1954
+ and `BatchHttpLink`, you can use `BaseHttpLink` or `BaseBatchHttpLink` instead.
1955
+ These links come without the `ClientAwarenessLink` included.
1956
+
1957
+ For example:
1958
+
1959
+ ```diff
1960
+ import {
1961
+ ApolloClient,
1962
+ - HttpLink,
1963
+ } from "@apollo/client";
1964
+ +import { BaseHttpLink } from "@apollo/client/link/http";
1965
+
1966
+ const client = new ApolloClient({
1967
+ - link: new HttpLink({
1968
+ + link: new BaseHttpLink({
1969
+ uri,
1970
+ }),
1971
+ cache: new InMemoryCache(),
1972
+ });
1973
+ ```
1974
+
1975
+ - [#12647](https://github.com/apollographql/apollo-client/pull/12647) [`a70fac6`](https://github.com/apollographql/apollo-client/commit/a70fac6dd8f26b46c813723a7206e55bfb677690) Thanks [@phryneas](https://github.com/phryneas)! - Added a new `.stop` function on `ObservableQuery`.
1976
+ Calling this method will unsubscribe all current subscribers by sending a `complete` event from the observable and tear down the `ObservableQuery`.
1977
+
1978
+ - [#12576](https://github.com/apollographql/apollo-client/pull/12576) [`a92ff78`](https://github.com/apollographql/apollo-client/commit/a92ff780abee60896bb9632867e90c82d0829255) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a `client` property to the `operation` passed to the link chain. This `client` is set as the `client` making the request to the link chain.
1979
+
1980
+ - [#12532](https://github.com/apollographql/apollo-client/pull/12532) [`ae0dcad`](https://github.com/apollographql/apollo-client/commit/ae0dcad89924e6b8090ca3182df30e528589b562) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add ability to specify a default `delay` for all mocked responses passed to `MockLink`. This `delay` can be configured globally (all instances of `MockLink` will use the global defaults), or per-instance (all mocks in a single instance will use the defaults). A `delay` defined on a single mock will supercede all default delays. Per-instance defaults supercede global defaults.
1981
+
1982
+ **Global defaults**
1983
+
1984
+ ```ts
1985
+ MockLink.defaultOptions = {
1986
+ // Use a default delay of 20ms for all mocks in all instances without a specified delay
1987
+ delay: 20,
1988
+
1989
+ // altenatively use a callback which will be executed for each mock
1990
+ delay: () => getRandomNumber(),
1991
+
1992
+ // or use the built-in `realisticDelay`. This is the default
1993
+ delay: realisticDelay(),
1994
+ };
1995
+ ```
1996
+
1997
+ **Per-instance defaults**
1998
+
1999
+ ```ts
2000
+ new MockLink(
2001
+ [
2002
+ // Use the default delay
2003
+ {
2004
+ request: { query },
2005
+ result: { data: { greeting: "Hello" } },
2006
+ },
2007
+ {
2008
+ request: { query },
2009
+ result: { data: { greeting: "Hello" } },
2010
+ // Override the default for this mock
2011
+ delay: 10,
2012
+ },
2013
+ ],
2014
+ {
2015
+ defaultOptions: {
2016
+ // Use a default delay of 20ms for all mocks without a specified delay
2017
+ delay: 20,
2018
+
2019
+ // altenatively use a callback which will be executed for each mock
2020
+ delay: () => getRandomNumber(),
2021
+
2022
+ // or use the built-in `realisticDelay`. This is the default
2023
+ delay: realisticDelay(),
2024
+ },
2025
+ }
2026
+ );
2027
+ ```
2028
+
2029
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Many of the types exported from `@apollo/client/link` now live on the `ApolloLink` namespace. The old types are now deprecated in favor of the namespaced types.
2030
+
2031
+ - `FetchResult` -> `ApolloLink.Result`
2032
+ - `GraphQLRequest` -> `ApolloLink.Request`
2033
+ - `NextLink` -> `ApolloLink.ForwardFunction`
2034
+ - `Operation` -> `ApolloLink.Operation`
2035
+ - `RequestHandler` -> `ApolloLink.RequestHandler`
2036
+
2037
+ - [#12714](https://github.com/apollographql/apollo-client/pull/12714) [`0e39469`](https://github.com/apollographql/apollo-client/commit/0e394692eaf0f8d8e506d8304935deafa952accf) Thanks [@phryneas](https://github.com/phryneas)! - The `FetchMoreQueryOptions` type has been inlined into `FetchMoreOptions`, and
2038
+ `FetchMoreQueryOptions` has been removed.
2039
+
2040
+ - [#12757](https://github.com/apollographql/apollo-client/pull/12757) [`5fd2e7c`](https://github.com/apollographql/apollo-client/commit/5fd2e7c15eecc6469ecf5f4fb116633b056ad103) Thanks [@phryneas](https://github.com/phryneas)! - Add `dataState` and overridable `DataValue` types to `useFragment`
2041
+
2042
+ - [#12757](https://github.com/apollographql/apollo-client/pull/12757) [`5fd2e7c`](https://github.com/apollographql/apollo-client/commit/5fd2e7c15eecc6469ecf5f4fb116633b056ad103) Thanks [@phryneas](https://github.com/phryneas)! - Add overridable `DataValue` types to `useSuspenseFragment`
2043
+
2044
+ - [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - Prioritize usage of `FormattedExecutionResult` over `FetchResult` where applicable.
2045
+
2046
+ Many APIs used `FetchResult` in place of `FormattedExecutionResult`, which could
2047
+ cause inconsistencies.
2048
+
2049
+ - `FetchResult` is now used to refer to an unhandled "raw" result as returned from
2050
+ a link.
2051
+ This can also include incremental results that use a different format.
2052
+ - `FormattedExecutionResult` from the `graphql` package is now used to represent
2053
+ the execution of a standard GraphQL request without incremental results.
2054
+
2055
+ If your custom links access the `data` property, you might need to first check if
2056
+ the result is a standard GraphQL result by using the `isFormattedExecutionResult`
2057
+ helper from `@apollo/client/utilities`.
2058
+
2059
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The static `ApolloLink.concat` method is now deprecated in favor of `ApolloLink.from`. `ApolloLink.concat` is now an alias for `ApolloLink.from` so prefer `ApolloLink.from` instead.
2060
+
2061
+ - [#12488](https://github.com/apollographql/apollo-client/pull/12488) [`c98b633`](https://github.com/apollographql/apollo-client/commit/c98b6335de5b15e546aa5db79a8cf2dc9d914dcf) Thanks [@phryneas](https://github.com/phryneas)! - Add a new method for static SSR of React components, `prerenderStatic`.
2062
+ The old methods, `getDataFromTree`, `getMarkupFromTree` and `renderToStringWithData`
2063
+ have been deprecated in favor of `prerenderStatic`.
2064
+
2065
+ If used with React 19 and the `prerender` or `prerenderToNodeStream` apis from
2066
+ `react-dom/static`, this method can now be used to SSR-prerender suspense-enabled
2067
+ hook APIs.
2068
+
2069
+ - [#12698](https://github.com/apollographql/apollo-client/pull/12698) [`be77d1a`](https://github.com/apollographql/apollo-client/commit/be77d1a6ddf719cab4780a0679fcd98556ac7f22) Thanks [@phryneas](https://github.com/phryneas)! - Adds an `accept` option to `HttpOptions` that allows to add additional `Accept` headers to be merged in without overriding user-specified or default accept headers.
2070
+
2071
+ - [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - The `mutationResult` option passed to the `updateQueries` callback now has an
2072
+ additional property, `dataState` with possible values of `"complete"` and `"streaming"`.
2073
+ This indicates whether the `data` value is of type
2074
+
2075
+ - `Unmasked<TData>` (if `"complete"`)
2076
+ - `Streaming<Unmasked<TData>>` (if `"streaming"`)
2077
+
2078
+ - [#12487](https://github.com/apollographql/apollo-client/pull/12487) [`b695e5e`](https://github.com/apollographql/apollo-client/commit/b695e5e10ab0eb47948e914b610f67c40267349e) Thanks [@phryneas](https://github.com/phryneas)! - Split out SSR-specific code from useQuery hook, remove RenderPromises
2079
+
2080
+ - [#12725](https://github.com/apollographql/apollo-client/pull/12725) [`89ac725`](https://github.com/apollographql/apollo-client/commit/89ac7256a34b3b04fe2cf83937b5494b375ce36d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `operationType` to `operation` in `ApolloLink`. This means that determining whether a `query` is a specific operation type can now be compared with this property instead of using `getMainDefinition`.
2081
+
2082
+ ```diff
2083
+ - import { getMainDefinition } from "@apollo/client/utilities";
2084
+ + import { OperationTypeNode } from "graphql";
2085
+
2086
+ ApolloLink.split(
2087
+ - ({ query }) => {
2088
+ - const definition = getMainDefinition(query);
2089
+ - return (
2090
+ - definition.kind === 'OperationDefinition' &&
2091
+ - definition.operation === 'subscription'
2092
+ - );
2093
+ - return
2094
+ - },
2095
+ + ({ operationType }) => {
2096
+ + return operationType === OperationTypeNode.SUBSCRIPTION;
2097
+ + },
2098
+ conditionTrueLink,
2099
+ conditionFalseLink,
2100
+ );
2101
+ ```
2102
+
2103
+ - [#12633](https://github.com/apollographql/apollo-client/pull/12633) [`9bfb51f`](https://github.com/apollographql/apollo-client/commit/9bfb51fdbca69560da71f9012c74ee172b6c2b69) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery.refetch` and `ObservableQuery.reobserve` and the `execute` function of `useLazyQuery` now return a
2104
+ `ResultPromise` with an additional `.retain` method.
2105
+ If this method is called, the underlying network operation will be kept running even if the `ObservableQuery` itself does
2106
+ not require the result anymore, and the Promise will resolve with the final result instead of resolving with an intermediate
2107
+ result in the case of early cancellation.
2108
+
2109
+ - [#12649](https://github.com/apollographql/apollo-client/pull/12649) [`0be92ad`](https://github.com/apollographql/apollo-client/commit/0be92ad51cf8de444fa1cc507bab2c21d230a44e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a new `dataState` property that determines the completeness of the `data` property. `dataState` helps narrow the type of `data`. `dataState` is now emitted from `ObservableQuery` and returned from all React hooks that return a `data` property.
2110
+
2111
+ The `dataState` values are:
2112
+
2113
+ - `empty`: No data could be fulfilled from the cache or the result is incomplete. `data` is `undefined`.
2114
+ - `partial`: Some data could be fulfilled from the cache but `data` is incomplete. This is only possible when `returnPartialData` is `true`.
2115
+ - `streaming`: `data` is incomplete as a result of a deferred query and the result is still streaming in.
2116
+ - `complete`: `data` is a fully satisfied query result fulfilled either from the cache or network.
2117
+
2118
+ Example:
2119
+
2120
+ ```ts
2121
+ const { data, dataState } = useQuery<TData>(query);
2122
+
2123
+ if (dataState === "empty") {
2124
+ expectTypeOf(data).toEqualTypeOf<undefined>();
2125
+ }
2126
+
2127
+ if (dataState === "partial") {
2128
+ expectTypeOf(data).toEqualTypeOf<DeepPartial<TData>>();
2129
+ }
2130
+
2131
+ if (dataState === "streaming") {
2132
+ expectTypeOf(data).toEqualTypeOf<TData>();
2133
+ }
2134
+
2135
+ if (dataState === "complete") {
2136
+ expectTypeOf(data).toEqualTypeOf<TData>();
2137
+ }
2138
+ ```
2139
+
2140
+ </details>
2141
+ <details>
2142
+
2143
+ <summary>
2144
+
2145
+ ### Patch Changes
2146
+
2147
+ </summary>
2148
+
2149
+ - [#12574](https://github.com/apollographql/apollo-client/pull/12574) [`0098ec9`](https://github.com/apollographql/apollo-client/commit/0098ec9f860e4e08a2070823f723dce401ae588a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Export `gql` from the `@apollo/client/react` entrypoint.
2150
+
2151
+ - [#12631](https://github.com/apollographql/apollo-client/pull/12631) [`b147cac`](https://github.com/apollographql/apollo-client/commit/b147cac5c96c44bfc3deb72c12c7521981584c12) Thanks [@phryneas](https://github.com/phryneas)! - When updating `skip` from `false` to `true` in `useQuery`, retain `data` if it is available rather than setting it to `undefined`.
2152
+
2153
+ - [#12822](https://github.com/apollographql/apollo-client/pull/12822) [`103664d`](https://github.com/apollographql/apollo-client/commit/103664dc93c0a7097eaec1a5144e769eb4fb7a31) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `HttpLink.ContextOptions` and `BatchHttpLink.ContextOptions` include `ClientAwarenessLink.ContextOptions`.
2154
+
2155
+ - [#12291](https://github.com/apollographql/apollo-client/pull/12291) [`ae5d06a`](https://github.com/apollographql/apollo-client/commit/ae5d06ac45ca6584d3c79aa417dae22f37a7d3b6) Thanks [@phryneas](https://github.com/phryneas)! - Remove deprecated `resetApolloContext` export
2156
+
2157
+ - [#12728](https://github.com/apollographql/apollo-client/pull/12728) [`07a0c8c`](https://github.com/apollographql/apollo-client/commit/07a0c8c52774793b254ecc91e5d4632bfdf48093) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Export the `IgnoreModifier` type from `@apollo/client/cache`.
2158
+
2159
+ - [#12776](https://github.com/apollographql/apollo-client/pull/12776) [`bce9b74`](https://github.com/apollographql/apollo-client/commit/bce9b7448a226b109cbe8f14911503fb09f37825) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache.watchFragment` now returns an `Unmasked<TData>` result since `cache.watchFragment` does not mask fragment spreads.
2160
+
2161
+ - [#12735](https://github.com/apollographql/apollo-client/pull/12735) [`5159880`](https://github.com/apollographql/apollo-client/commit/51598808851e16af722baaefbd1f90534332e07a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Change the `unsafePreviousData` argument on `UpdateQueryMapFn` and `SubscribeToMoreQueryFn` to a `DeepPartial` since the result may contain partial data.
2162
+
2163
+ - [#12536](https://github.com/apollographql/apollo-client/pull/12536) [`e14205a`](https://github.com/apollographql/apollo-client/commit/e14205ad5909f95aa04684acd0ca2f25956ee50c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The returned `networkStatus` in `useLazyQuery` is now set to `setVariables` when calling the `useLazyQuery` `execute` function for the first time with variables.
2164
+
2165
+ - [#12748](https://github.com/apollographql/apollo-client/pull/12748) [`e1ca85e`](https://github.com/apollographql/apollo-client/commit/e1ca85eab181d8e16d945e849dfb13352902f197) Thanks [@phryneas](https://github.com/phryneas)! - Fix a bug where the new `operationType` property wasn't passed into `operation`.
2166
+
2167
+ - [#12709](https://github.com/apollographql/apollo-client/pull/12709) [`9d42e2a`](https://github.com/apollographql/apollo-client/commit/9d42e2a08d3ddfdfdfc7ac65bd66985da5642e7d) Thanks [@phryneas](https://github.com/phryneas)! - Remove these incremental-format-specific types:
2168
+
2169
+ - `ExecutionPatchIncrementalResult`
2170
+ - `ExecutionPatchInitialResult`
2171
+ - `ExecutionPatchResult`
2172
+ - `IncrementalPayload`
2173
+ - `Path`
2174
+
2175
+ - [#12618](https://github.com/apollographql/apollo-client/pull/12618) [`e4a3ecf`](https://github.com/apollographql/apollo-client/commit/e4a3ecfe50bc5b462067574a0ffb1951549fb60f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove code that strips `@client` fields in `HttpLink` and `BatchHttpLink`. This was unused code since core handles removing `@client` fields and should have no observable change.
2176
+
2177
+ - [#12536](https://github.com/apollographql/apollo-client/pull/12536) [`e14205a`](https://github.com/apollographql/apollo-client/commit/e14205ad5909f95aa04684acd0ca2f25956ee50c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `ObservableQuery` stops polling if switching to a `standby` `fetchPolicy`. When switching back to a non-`standby` `fetchPolicy`, polling will resume.
2178
+
2179
+ - [#12677](https://github.com/apollographql/apollo-client/pull/12677) [`94e58ed`](https://github.com/apollographql/apollo-client/commit/94e58ed75fc547ff037d9efeeba929fd61b20c4c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Downgrade minimum supported `rxjs` peer dependency version to 7.3.0.
2180
+
2181
+ - [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `variables` option used with various APIs are now enforced more consistently across the client when `TVariables` contains required variables. If required `variables` are not provided, TypeScript will now complain that it requires a `variables` option.
2182
+
2183
+ This change affects the following APIs:
2184
+
2185
+ - `client.query`
2186
+ - `client.mutate`
2187
+ - `client.subscribe`
2188
+ - `client.watchQuery`
2189
+ - `useBackgroundQuery`
2190
+ - `useQuery`
2191
+ - `useSubscription`
2192
+ - `useSuspenseQuery`
2193
+
2194
+ - [#12451](https://github.com/apollographql/apollo-client/pull/12451) [`77e1b13`](https://github.com/apollographql/apollo-client/commit/77e1b133bdba32c67b5a840090dbacb16282dee9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Default `TVariables` generic type to `OperationVariables` instead of `any` throughout the client in areas that did not yet have the default as such.
2195
+
2196
+ - [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix type of `variables` returned from `useLazyQuery`. When `called` is `false`, `variables` is now `Partial<TVariables>` instead of `TVariables`.
2197
+
2198
+ - [#12402](https://github.com/apollographql/apollo-client/pull/12402) [`903c3ef`](https://github.com/apollographql/apollo-client/commit/903c3ef9f77280492c298b4d8e5f96f110e3cda1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Use an an empty object (`{}`) rather than an object with `null` prototype (`Object.create(null)`) in all areas that instantiate objects.
2199
+
2200
+ - [#12734](https://github.com/apollographql/apollo-client/pull/12734) [`037979d`](https://github.com/apollographql/apollo-client/commit/037979dc47ffb7125429707471d901a08db49283) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't warn about a missing resolver if a `@client` does not have a configured resolver. It is possible the cache contains a `read` function for the field and the warning added confusion.
2201
+
2202
+ Note that `read` functions without a defined resolver will receive the `existing` argument as `null` instead of `undefined` even when data hasn't been written to the cache. This is because `LocalState` sets a default value of `null` when a resolver is not defined to ensure that the field contains a value in case a `read` function is not defined rather than omitting the field entirely.
2203
+
2204
+ - [#12536](https://github.com/apollographql/apollo-client/pull/12536) [`e14205a`](https://github.com/apollographql/apollo-client/commit/e14205ad5909f95aa04684acd0ca2f25956ee50c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure a loading state is emitted when calling the `execute` function after changing clients in `useLazyQuery`.
2205
+
2206
+ - [#12370](https://github.com/apollographql/apollo-client/pull/12370) [`0517163`](https://github.com/apollographql/apollo-client/commit/05171634404a44231329bf63eee960db52d08b25) Thanks [@phryneas](https://github.com/phryneas)! - `InMemoryCache`: Fields with an empty argument object are now saved the same way as fields without arguments.
2207
+
2208
+ Previously, it was possible that the reponses for these two queries would be stored differently in the cache:
2209
+
2210
+ ```gql
2211
+ query PlainAccess {
2212
+ myField
2213
+ }
2214
+ ```
2215
+
2216
+ would be stored as `myField`
2217
+ and
2218
+
2219
+ ```gql
2220
+ query AccessWithoutOptionalArgument($optional: String) {
2221
+ myField(optional: $optional)
2222
+ }
2223
+ ```
2224
+
2225
+ would be stored as `myField({"optional":"Foo"})` if called with `{optional: "Foo"}` and as `myField({})` if called without the optional argument.
2226
+
2227
+ The cases `myField` and `myField({})` are equivalent from the perspective of a GraphQL server, and so in the future both of these will be stored as `myField` in the cache.
2228
+
2229
+ - [#12385](https://github.com/apollographql/apollo-client/pull/12385) [`cad5117`](https://github.com/apollographql/apollo-client/commit/cad511723a1b8b0ac2042cf49435f7affb0dc4e4) Thanks [@phryneas](https://github.com/phryneas)! - \* dropped the deprecated `DEV` export from `@apollo/client/utilities` and `@apollo/client/utilities/globals`
2230
+
2231
+ - moved the `__DEV__` export from `@apollo/client/utilities/globals` to `@apollo/client/utilities/environment`
2232
+ - moved the `invariant`, `newInvariantError` and `InvariantError` exports from `@apollo/client/utilities/globals` to `@apollo/client/utilities/invariant`
2233
+
2234
+ - [#12709](https://github.com/apollographql/apollo-client/pull/12709) [`9d42e2a`](https://github.com/apollographql/apollo-client/commit/9d42e2a08d3ddfdfdfc7ac65bd66985da5642e7d) Thanks [@phryneas](https://github.com/phryneas)! - Slightly rework multipart response parsing.
2235
+
2236
+ This removes last incremental-protocol-specific details from `HttpLink` and `BatchHttpLink`.
2237
+
2238
+ - [#12824](https://github.com/apollographql/apollo-client/pull/12824) [`0506f12`](https://github.com/apollographql/apollo-client/commit/0506f12936d3fe7c840e5d56a5efa20bbce1525e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `RetryLink` now emits a `next` event instead of an `error` event when encountering a protocol errors for multipart subscriptions when the operation is not retried. This ensures the observable notification remains the same as when `RetryLink` is not used.
2239
+
2240
+ - [#12487](https://github.com/apollographql/apollo-client/pull/12487) [`b695e5e`](https://github.com/apollographql/apollo-client/commit/b695e5e10ab0eb47948e914b610f67c40267349e) Thanks [@phryneas](https://github.com/phryneas)! - `useQuery` with `ssr: false` - previously, `skip` had a higher priortity than `ssr: false` while `ssr: false` had a higher priority than `fetchPolicy: "standby"` (which is roughly equivalent to `skip`).
2241
+
2242
+ This priority has been adjusted so now both `skip` and `fetchPolicy: "standby"` have a higher priority than `ssr: false` and will return `loading: false`, while `ssr: false` will only come after those and will return `loading: true` if those are not set.
2243
+
2244
+ - [#12725](https://github.com/apollographql/apollo-client/pull/12725) [`89ac725`](https://github.com/apollographql/apollo-client/commit/89ac7256a34b3b04fe2cf83937b5494b375ce36d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Export `getMainDefinition` from `@apollo/client/utilities`.
2245
+
2246
+ - [#12716](https://github.com/apollographql/apollo-client/pull/12716) [`ad88976`](https://github.com/apollographql/apollo-client/commit/ad889766882b4817e50e8e819044bc5ed772173b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump only to release latest as `rc`.
2247
+
2248
+ - [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where passing `onError` to `useMutation` would resolve the promise returned by the `mutate` function instead of rejecting when using an `errorPolicy` of `none`.
2249
+
2250
+ - [#12542](https://github.com/apollographql/apollo-client/pull/12542) [`afb4fce`](https://github.com/apollographql/apollo-client/commit/afb4fce08859b2c6eebf288230a7c35b7acf2da6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `useLazyQuery` does not return a `partial` property which is not specified by the result type.
2251
+
2252
+ - [#12432](https://github.com/apollographql/apollo-client/pull/12432) [`c7c2f61`](https://github.com/apollographql/apollo-client/commit/c7c2f6122c874eed16d5621be26992f86d9756eb) Thanks [@phryneas](https://github.com/phryneas)! - ObservableQuery: implement the `rxjs` `InteropObservable` interface to ensure `from(observableQuery)` stays possible
2253
+
2254
+ - [#12775](https://github.com/apollographql/apollo-client/pull/12775) [`454ec78`](https://github.com/apollographql/apollo-client/commit/454ec78b751853da07243174a6f9bdc4535e7e8f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't export `gql` from `@apollo/client/react` entrypoint. Import from `@apollo/client` instead.
2255
+
2256
+ - [#12385](https://github.com/apollographql/apollo-client/pull/12385) [`cad5117`](https://github.com/apollographql/apollo-client/commit/cad511723a1b8b0ac2042cf49435f7affb0dc4e4) Thanks [@phryneas](https://github.com/phryneas)! - `@apollo/client`, `@apollo/client/core` and `@apollo/client/cache` no longer export an empty `Cache` runtime object. This is meant to be a type-only namespace.
2257
+
2258
+ - [#12513](https://github.com/apollographql/apollo-client/pull/12513) [`9c3207c`](https://github.com/apollographql/apollo-client/commit/9c3207c44ddad1f8b845c09495d6c070ace8de7b) Thanks [@phryneas](https://github.com/phryneas)! - Removed the `parser` cache. The functionality has been replaced in a way that doesn't need caching.
2259
+
2260
+ - [#12465](https://github.com/apollographql/apollo-client/pull/12465) [`a132163`](https://github.com/apollographql/apollo-client/commit/a1321637cafb4023d6df416e9467294114d8346b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Rename all React hook result types and options. These types have all moved under a namespace that matches the hook name. For example, `useQuery` exports `useQuery.Options` and `useQuery.Result` types. As such, the old hook types have been deprecated and will be removed in v5.
2261
+
2262
+ - [#12739](https://github.com/apollographql/apollo-client/pull/12739) [`b184754`](https://github.com/apollographql/apollo-client/commit/b184754d08810df9a7838615990e90a960966037) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix type of `error` argument on the `onError` option for `subscribeToMore` to `ErrorLike`.
2263
+
2264
+ - [#12572](https://github.com/apollographql/apollo-client/pull/12572) [`3dc50e6`](https://github.com/apollographql/apollo-client/commit/3dc50e6476dcedf82ed3856bf9f4571a32a760a6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Adjust `useMutation` types to better handle required variables. When required variables are missing, TypeScript will now complain if they are not provided either to the hook or the returned `mutate` function. Providing required variables to `useMutation` will make them optional in the returned `mutate` function.
2265
+
2266
+ - [#12819](https://github.com/apollographql/apollo-client/pull/12819) [`7ff548d`](https://github.com/apollographql/apollo-client/commit/7ff548dab0f38bfe315fce6cc51105c93d112271) Thanks [@jerelmiller](https://github.com/jerelmiller)! - update type of `HttpLink.Options.fetchOptions` to `RequestInit`
2267
+
2268
+ - [#12761](https://github.com/apollographql/apollo-client/pull/12761) [`db6f7c3`](https://github.com/apollographql/apollo-client/commit/db6f7c3823aaf58ee403ef45f0e817241b1c56a2) Thanks [@phryneas](https://github.com/phryneas)! - Deprecate second argument to `readFragment` and `readQuery` - `optimistic` should be passed as part of the object in the first argument instead.
2269
+
2270
+ - [#12820](https://github.com/apollographql/apollo-client/pull/12820) [`fba3d9e`](https://github.com/apollographql/apollo-client/commit/fba3d9ec96cce9f1a89908e4f33361e27d1f52b4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `fetchOptions` option provided to `HttpLink` and `BatchHttpLink` is now `RequestInit` instead of `any`. The `credentials` option is now a `RequestCredentials` type instead of a `string`.
2271
+
2272
+ - [#12650](https://github.com/apollographql/apollo-client/pull/12650) [`2a32ac6`](https://github.com/apollographql/apollo-client/commit/2a32ac6d38de2be0be6891a969ee4f5e3bbca629) Thanks [@phryneas](https://github.com/phryneas)! - Fix a situation where a passed-in `AbortSignal` would override internal unsubscription cancellation behaviour.
2273
+
2274
+ - [#12562](https://github.com/apollographql/apollo-client/pull/12562) [`90bf0e6`](https://github.com/apollographql/apollo-client/commit/90bf0e61516a382182f212ac8ab891099e2eb009) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `client.query` no longer supports `notifyOnNetworkStatusChange` in options. An error will be thrown if this option is set. The effects of this option were not observable by `client.query` since `client.query` emits a single result.
2275
+
2276
+ - [#12557](https://github.com/apollographql/apollo-client/pull/12557) [`51d26ae`](https://github.com/apollographql/apollo-client/commit/51d26ae631c6631a189c98ea9357b18e77a9a876) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Update format of the error message for `CombinedGraphQLErrors` and `CombinedProtocolErrors` to be more like v3.x.
2277
+
2278
+ ```diff
2279
+ console.log(error.message);
2280
+ - `The GraphQL server returned with errors:
2281
+ - - Email not found
2282
+ - - Username already in use`
2283
+ + `Email not found
2284
+ + Username already in use`
2285
+ ```
2286
+
2287
+ - [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The individual `empty`, `concat`, `from` and `split` functions exported from `@apollo/client/link` are now deprecated in favor of using the static functions instead.
2288
+
2289
+ ```diff
2290
+ import {
2291
+ ApolloLink,
2292
+ - concat,
2293
+ - empty,
2294
+ - from,
2295
+ - split,
2296
+ } from "@apollo/client/link";
2297
+
2298
+ - concat(first, second);
2299
+ + ApolloLink.concat(first, second);
2300
+
2301
+ - empty();
2302
+ + ApolloLink.empty();
2303
+
2304
+ - from([first, second]);
2305
+ + ApolloLink.from([first, second]);
2306
+
2307
+ - split(
2308
+ + ApolloLink.split(
2309
+ (operation) => /* */,
2310
+ first,
2311
+ second
2312
+ );
2313
+ ```
2314
+
2315
+ - [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - The incremental delivery (`@defer` support) implementation is now pluggable.
2316
+
2317
+ `ApolloClient` now per default ships without an incremental format implementation
2318
+ and allows you to swap in the format that you want to use.
2319
+
2320
+ Usage looks like this:
2321
+
2322
+ ```ts
2323
+ import {
2324
+ // this is the default
2325
+ NotImplementedHandler,
2326
+ // this implements the `@defer` transport format that ships with Apollo Router
2327
+ Defer20220824Handler,
2328
+ // this implements the `@defer` transport format that ships with GraphQL 17.0.0-alpha.2
2329
+ GraphQL17Alpha2Handler,
2330
+ } from "@apollo/client/incremental";
2331
+
2332
+ const client = new ApolloClient({
2333
+ cache: new InMemoryCache({
2334
+ /*...*/
2335
+ }),
2336
+ link: new HttpLink({
2337
+ /*...*/
2338
+ }),
2339
+ incrementalHandler: new Defer20220824Handler(),
2340
+ });
2341
+ ```
2342
+
2343
+ We will add handlers for other response formats that can be swapped this way
2344
+ during the lifetime of Apollo Client 4.0.
2345
+
2346
+ - [#12454](https://github.com/apollographql/apollo-client/pull/12454) [`925548a`](https://github.com/apollographql/apollo-client/commit/925548a9baadb19b7bb78ee84c6f9e64b55c39e9) Thanks [@phryneas](https://github.com/phryneas)! - Fix up the 4.0 CommonJS build
2347
+
2348
+ - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't emit a partial cache result from `cache-only` queries when `returnPartialData` is `false`.
2349
+
2350
+ - [#12631](https://github.com/apollographql/apollo-client/pull/12631) [`b147cac`](https://github.com/apollographql/apollo-client/commit/b147cac5c96c44bfc3deb72c12c7521981584c12) Thanks [@phryneas](https://github.com/phryneas)! - The `error` property is no longer present when `skip` is `true` in `useQuery`.
2351
+
2352
+ - [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.variables` has been updated to return `TVariables` rather than `TVariables | undefined`. This is more consistent with the runtime value where an empty object (`{}`) will be returned when the `variables` option is not provided.
2353
+
2354
+ - [#12823](https://github.com/apollographql/apollo-client/pull/12823) [`19e315e`](https://github.com/apollographql/apollo-client/commit/19e315e316ae458913f4d11961b0a2a365df0a19) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix the type of the argument for the `sha256` function for `PersistedQueryLink` from `...any[]` to `string`.
2355
+
2356
+ - [#12729](https://github.com/apollographql/apollo-client/pull/12729) [`699c830`](https://github.com/apollographql/apollo-client/commit/699c8305639ff69bab36fd2214defbe1ac6f0b18) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `useQuery` rerenders when `notifyOnNetworkStatusChange` is `false` and a `refetch` that changes variables returns a result deeply equal to previous variables.
2357
+
2358
+ - [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where additional response properties were returned on the result returned from `client.mutate`, such as `@defer` payload fields. These properties are now stripped out to correspond to the TypeScript type.
2359
+
2360
+ - [#12821](https://github.com/apollographql/apollo-client/pull/12821) [`223a409`](https://github.com/apollographql/apollo-client/commit/223a4094f401bbe7fd3e4c249fa405843b63ba2e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a deprecation warning to `WebSocketLink`.
2361
+
2362
+ - [#12782](https://github.com/apollographql/apollo-client/pull/12782) [`742b3a0`](https://github.com/apollographql/apollo-client/commit/742b3a0ed65d28818974e56225c86ab7e350e677) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move `ApolloClient`, `ObservableQuery`, and `ApolloCache.watchFragment` method options and result types into namespaces. The old types are now exported as deprecated.
2363
+
2364
+ - [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - Fixed a bug in `PersistedQueryLink` where the `persistedQuery` extension would still be sent after a `PersistedQueryNotSupported` if `includeExtensions` was enabled on `HttpLink`.
2365
+
2366
+ </details>
2367
+
2368
+ ## 4.0.0-rc.13
2369
+
2370
+ ### Major Changes
2371
+
2372
+ - [#12850](https://github.com/apollographql/apollo-client/pull/12850) [`268cd80`](https://github.com/apollographql/apollo-client/commit/268cd800a2d73305c0df8dd38b6bd1cee98f0fec) Thanks [@phryneas](https://github.com/phryneas)! - Introduce a versioning policy.
2373
+
2374
+ ## 4.0.0-rc.12
2375
+
2376
+ ### Minor Changes
2377
+
2378
+ - [#12838](https://github.com/apollographql/apollo-client/pull/12838) [`b005561`](https://github.com/apollographql/apollo-client/commit/b0055613c1f4837e994d2d0756348d553e2f302f) Thanks [@phryneas](https://github.com/phryneas)! - Add an entrypoint at `@apollo/client/v4-migration` that includes removed values and types. Each export includes doc blocks on how to migrate away from the removed type.
2379
+
2380
+ ## 4.0.0-rc.11
2381
+
2382
+ ### Major Changes
2383
+
2384
+ - [#12840](https://github.com/apollographql/apollo-client/pull/12840) [`83e132a`](https://github.com/apollographql/apollo-client/commit/83e132ab1bacb3293da61dd4519379e36a1fb090) Thanks [@phryneas](https://github.com/phryneas)! - If you use an incremental delivery handler, you now have to explicitly opt into adding the chunk types to the `ApolloLink.Result` type.
2385
+
2386
+ ```ts title="apollo-client.d.ts
2387
+ import { Defer20220824Handler } from "@apollo/client/incremental";
2388
+
2389
+ declare module "@apollo/client" {
2390
+ export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {}
2391
+ }
2392
+ ```
2393
+
2394
+ - [#12841](https://github.com/apollographql/apollo-client/pull/12841) [`65b503f`](https://github.com/apollographql/apollo-client/commit/65b503fe4bfcf942e8f66f36f622f5f6448d6731) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `DataMasking` interface exported from `@apollo/client` and `@apollo/client/masking`.
2395
+
2396
+ ## 4.0.0-rc.10
2397
+
2398
+ ### Major Changes
2399
+
2400
+ - [#12837](https://github.com/apollographql/apollo-client/pull/12837) [`7c49fdc`](https://github.com/apollographql/apollo-client/commit/7c49fdce2f40571d92c83602bbb1b5bd891f626b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - You must now opt in to use GraphQL Codegen data masking types when using Apollo Client's data masking feature. By default, Apollo Client now uses an identity type to apply to masked/unmasked types.
2401
+
2402
+ If you're using GraphQL Codegen to generate masked types, opt into the GraphQL Codegen masked types using declaration merging on the `TypeOverides` interface.
2403
+
2404
+ ```ts title="apollo-client.d.ts
2405
+ import { GraphQLCodegenDataMasking } from "@apollo/client/masking";
2406
+
2407
+ declare module "@apollo/client" {
2408
+ export interface TypeOverrides
2409
+ extends GraphQLCodegenDataMasking.TypeOverrides {}
2410
+ }
2411
+ ```
2412
+
2413
+ - [#12837](https://github.com/apollographql/apollo-client/pull/12837) [`7c49fdc`](https://github.com/apollographql/apollo-client/commit/7c49fdce2f40571d92c83602bbb1b5bd891f626b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The types mode for data masking has been removed. Adding a types mode to the `DataMasking` interface has no effect. Remove the `mode` key in the module where you declare the `DataMasking` type for the `@apollo/client` module.
2414
+
2415
+ As a result, the `Masked` and `MaskedDocumentNode` types have also been removed since these have no effect when types are preserved.
2416
+
3
2417
  ## 4.0.0-rc.9
4
2418
 
5
2419
  ### Minor Changes
@@ -2167,6 +4581,76 @@
2167
4581
 
2168
4582
  - [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't emit a partial cache result from `cache-only` queries when `returnPartialData` is `false`.
2169
4583
 
4584
+ ## 3.14.0
4585
+
4586
+ ### Minor Changes
4587
+
4588
+ - [#12752](https://github.com/apollographql/apollo-client/pull/12752) [`8b779b4`](https://github.com/apollographql/apollo-client/commit/8b779b428b9dc9dad3e78f02bba6646ff415631d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings to remaining APIs changed in Apollo Client 4.0.
4589
+
4590
+ - [#12746](https://github.com/apollographql/apollo-client/pull/12746) [`0bcd2f4`](https://github.com/apollographql/apollo-client/commit/0bcd2f4ead372eb5928bbd5c00b0bd48e497a5e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add warnings and deprecations for options and methods for all React APIs.
4591
+
4592
+ - [#12751](https://github.com/apollographql/apollo-client/pull/12751) [`567cad8`](https://github.com/apollographql/apollo-client/commit/567cad8fcc30ac3b82560abc24970d33f160622e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `@deprecated` tags to all properties returned from any query API (e.g. `client.query`, `observableQuery.refetch`, etc.), `client.mutate`, and `client.subscribe` that are no longer available in Apollo Client 4.0.
4593
+
4594
+ - [#12746](https://github.com/apollographql/apollo-client/pull/12746) [`0bcd2f4`](https://github.com/apollographql/apollo-client/commit/0bcd2f4ead372eb5928bbd5c00b0bd48e497a5e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `preloadQuery.toPromise(queryRef)` as a replacement for `queryRef.toPromise()`. `queryRef.toPromise()` has been removed in Apollo Client 4.0 in favor of `preloadQuery.toPromise` and is now considered deprecated.
4595
+
4596
+ - [#12736](https://github.com/apollographql/apollo-client/pull/12736) [`ea89440`](https://github.com/apollographql/apollo-client/commit/ea8944013278060ef87dfa4de6663a21b5204880) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and deprecation warnings for `ApolloClient` options and methods.
4597
+
4598
+ - [#12763](https://github.com/apollographql/apollo-client/pull/12763) [`5de6a3d`](https://github.com/apollographql/apollo-client/commit/5de6a3d3189afa2a7c3bb2eb08d3c4394ae4a16d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump only to release latest as `rc`.
4599
+
4600
+ - [#12459](https://github.com/apollographql/apollo-client/pull/12459) [`1c5a031`](https://github.com/apollographql/apollo-client/commit/1c5a0313d388945aeda93b2c1992ad77f4416fa1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Reset `addTypenameTransform` and `fragments` caches when calling `cache.gc()` only when `resetResultCache` is `true`.
4601
+
4602
+ - [#12743](https://github.com/apollographql/apollo-client/pull/12743) [`92ad409`](https://github.com/apollographql/apollo-client/commit/92ad4097e5c83e0a780ede20db34e9e63fb98e8b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings for `addTypename` in `InMemoryCache` and `MockedProvider`.
4603
+
4604
+ - [#12743](https://github.com/apollographql/apollo-client/pull/12743) [`92ad409`](https://github.com/apollographql/apollo-client/commit/92ad4097e5c83e0a780ede20db34e9e63fb98e8b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings for `canonizeResults`.
4605
+
4606
+ - [#12751](https://github.com/apollographql/apollo-client/pull/12751) [`567cad8`](https://github.com/apollographql/apollo-client/commit/567cad8fcc30ac3b82560abc24970d33f160622e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Warn when using a `standby` fetch policy with `client.query`.
4607
+
4608
+ ### Patch Changes
4609
+
4610
+ - [#12750](https://github.com/apollographql/apollo-client/pull/12750) [`ecf3de1`](https://github.com/apollographql/apollo-client/commit/ecf3de1cc9a2cf3aaeba0c945909324b9e4b478a) Thanks [@phryneas](https://github.com/phryneas)! - Prevent field policies from overwriting/merging into supertype field policies.
4611
+
4612
+ ## 3.14.0-rc.0
4613
+
4614
+ ### Minor Changes
4615
+
4616
+ - [#12763](https://github.com/apollographql/apollo-client/pull/12763) [`5de6a3d`](https://github.com/apollographql/apollo-client/commit/5de6a3d3189afa2a7c3bb2eb08d3c4394ae4a16d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump only to release latest as `rc`.
4617
+
4618
+ ## 3.14.0-alpha.1
4619
+
4620
+ ### Minor Changes
4621
+
4622
+ - [#12752](https://github.com/apollographql/apollo-client/pull/12752) [`8b779b4`](https://github.com/apollographql/apollo-client/commit/8b779b428b9dc9dad3e78f02bba6646ff415631d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings to remaining APIs changed in Apollo Client 4.0.
4623
+
4624
+ - [#12751](https://github.com/apollographql/apollo-client/pull/12751) [`567cad8`](https://github.com/apollographql/apollo-client/commit/567cad8fcc30ac3b82560abc24970d33f160622e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `@deprecated` tags to all properties returned from any query API (e.g. `client.query`, `observableQuery.refetch`, etc.), `client.mutate`, and `client.subscribe` that are no longer available in Apollo Client 4.0.
4625
+
4626
+ - [#12751](https://github.com/apollographql/apollo-client/pull/12751) [`567cad8`](https://github.com/apollographql/apollo-client/commit/567cad8fcc30ac3b82560abc24970d33f160622e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Warn when using a `standby` fetch policy with `client.query`.
4627
+
4628
+ ## 3.14.0-alpha.0
4629
+
4630
+ ### Minor Changes
4631
+
4632
+ - [#12746](https://github.com/apollographql/apollo-client/pull/12746) [`0bcd2f4`](https://github.com/apollographql/apollo-client/commit/0bcd2f4ead372eb5928bbd5c00b0bd48e497a5e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add warnings and deprecations for options and methods for all React APIs.
4633
+
4634
+ - [#12746](https://github.com/apollographql/apollo-client/pull/12746) [`0bcd2f4`](https://github.com/apollographql/apollo-client/commit/0bcd2f4ead372eb5928bbd5c00b0bd48e497a5e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `preloadQuery.toPromise(queryRef)` as a replacement for `queryRef.toPromise()`. `queryRef.toPromise()` has been removed in Apollo Client 4.0 in favor of `preloadQuery.toPromise` and is now considered deprecated.
4635
+
4636
+ - [#12736](https://github.com/apollographql/apollo-client/pull/12736) [`ea89440`](https://github.com/apollographql/apollo-client/commit/ea8944013278060ef87dfa4de6663a21b5204880) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and deprecation warnings for `ApolloClient` options and methods.
4637
+
4638
+ - [#12459](https://github.com/apollographql/apollo-client/pull/12459) [`1c5a031`](https://github.com/apollographql/apollo-client/commit/1c5a0313d388945aeda93b2c1992ad77f4416fa1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Reset `addTypenameTransform` and `fragments` caches when calling `cache.gc()` only when `resetResultCache` is `true`.
4639
+
4640
+ - [#12743](https://github.com/apollographql/apollo-client/pull/12743) [`92ad409`](https://github.com/apollographql/apollo-client/commit/92ad4097e5c83e0a780ede20db34e9e63fb98e8b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings for `addTypename` in `InMemoryCache` and `MockedProvider`.
4641
+
4642
+ - [#12743](https://github.com/apollographql/apollo-client/pull/12743) [`92ad409`](https://github.com/apollographql/apollo-client/commit/92ad4097e5c83e0a780ede20db34e9e63fb98e8b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings for `canonizeResults`.
4643
+
4644
+ ### Patch Changes
4645
+
4646
+ - [#12750](https://github.com/apollographql/apollo-client/pull/12750) [`ecf3de1`](https://github.com/apollographql/apollo-client/commit/ecf3de1cc9a2cf3aaeba0c945909324b9e4b478a) Thanks [@phryneas](https://github.com/phryneas)! - Prevent field policies from overwriting/merging into supertype field policies.
4647
+
4648
+ ## 3.13.9
4649
+
4650
+ ### Patch Changes
4651
+
4652
+ - [#12804](https://github.com/apollographql/apollo-client/pull/12804) [`32c9aa9`](https://github.com/apollographql/apollo-client/commit/32c9aa9215fab72e9ab68ee71198ce242157f855) Thanks [@phryneas](https://github.com/phryneas)! - Fix a possible race condition on queries that were reobserved before they were subscribed to the first time.
4653
+
2170
4654
  ## 3.13.8
2171
4655
 
2172
4656
  ### Patch Changes