@apollo/client 4.0.0-alpha.10 → 4.0.0-alpha.12

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 (294) hide show
  1. package/.changeset/afraid-grapes-call.md +5 -0
  2. package/.changeset/brave-moons-juggle.md +5 -0
  3. package/.changeset/gentle-waves-cough.md +5 -0
  4. package/.changeset/lucky-sheep-explain.md +34 -0
  5. package/.changeset/orange-suits-laugh.md +5 -0
  6. package/.changeset/perfect-ducks-reflect.md +12 -0
  7. package/.changeset/pre.json +12 -0
  8. package/.changeset/seven-schools-carry.md +5 -0
  9. package/.changeset/short-tomatoes-attend.md +5 -0
  10. package/.changeset/silly-seas-confess.md +5 -0
  11. package/.changeset/small-poems-rest.md +5 -0
  12. package/.changeset/sour-kids-deliver.md +5 -0
  13. package/.changeset/witty-paws-marry.md +26 -0
  14. package/CHANGELOG.md +96 -0
  15. package/__cjs/cache/core/cache.cjs +1 -1
  16. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  17. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  18. package/__cjs/cache/inmemory/policies.cjs +4 -4
  19. package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
  20. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  21. package/__cjs/core/ApolloClient.cjs +17 -25
  22. package/__cjs/core/ApolloClient.cjs.map +1 -1
  23. package/__cjs/core/ApolloClient.d.cts +4 -21
  24. package/__cjs/core/LocalState.cjs +2 -3
  25. package/__cjs/core/LocalState.cjs.map +1 -1
  26. package/__cjs/core/LocalState.d.cts +1 -2
  27. package/__cjs/core/ObservableQuery.cjs +11 -11
  28. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  29. package/__cjs/core/QueryInfo.cjs.map +1 -1
  30. package/__cjs/core/QueryInfo.d.cts +1 -1
  31. package/__cjs/core/QueryManager.cjs +34 -33
  32. package/__cjs/core/QueryManager.cjs.map +1 -1
  33. package/__cjs/core/QueryManager.d.cts +16 -18
  34. package/__cjs/core/index.cjs +7 -7
  35. package/__cjs/core/index.cjs.map +1 -1
  36. package/__cjs/core/index.d.cts +4 -4
  37. package/__cjs/core/types.d.cts +8 -3
  38. package/__cjs/core/watchQueryOptions.d.cts +4 -4
  39. package/__cjs/errors/index.cjs.map +1 -1
  40. package/__cjs/errors/index.d.cts +1 -1
  41. package/__cjs/invariantErrorCodes.cjs +47 -37
  42. package/__cjs/link/batch/batchLink.cjs +2 -2
  43. package/__cjs/link/batch/batchLink.cjs.map +1 -1
  44. package/__cjs/link/batch/batchLink.d.cts +2 -2
  45. package/__cjs/link/batch/batching.cjs.map +1 -1
  46. package/__cjs/link/batch/batching.d.cts +1 -1
  47. package/__cjs/link/batch-http/batchHttpLink.cjs +2 -2
  48. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  49. package/__cjs/link/batch-http/batchHttpLink.d.cts +5 -4
  50. package/__cjs/link/context/index.cjs +2 -2
  51. package/__cjs/link/context/index.cjs.map +1 -1
  52. package/__cjs/link/context/index.d.cts +3 -4
  53. package/__cjs/link/core/ApolloLink.cjs +2 -2
  54. package/__cjs/link/core/ApolloLink.cjs.map +1 -1
  55. package/__cjs/link/core/ApolloLink.d.cts +2 -2
  56. package/__cjs/link/core/types.d.cts +19 -8
  57. package/__cjs/link/error/index.cjs +3 -3
  58. package/__cjs/link/error/index.cjs.map +1 -1
  59. package/__cjs/link/error/index.d.cts +2 -2
  60. package/__cjs/link/http/HttpLink.cjs +2 -2
  61. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  62. package/__cjs/link/http/HttpLink.d.cts +129 -4
  63. package/__cjs/link/http/createHttpLink.cjs +2 -2
  64. package/__cjs/link/http/createHttpLink.cjs.map +1 -1
  65. package/__cjs/link/http/createHttpLink.d.cts +3 -3
  66. package/__cjs/link/http/index.cjs.map +1 -1
  67. package/__cjs/link/http/index.d.cts +0 -1
  68. package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
  69. package/__cjs/link/http/parseAndCheckHttpResponse.d.cts +1 -1
  70. package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
  71. package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
  72. package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
  73. package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +8 -83
  74. package/__cjs/link/http/selectURI.cjs.map +1 -1
  75. package/__cjs/link/http/selectURI.d.cts +1 -1
  76. package/__cjs/link/{core/index.cjs → index.cjs} +6 -6
  77. package/__cjs/link/index.cjs.map +1 -0
  78. package/__cjs/link/index.d.cts +8 -0
  79. package/__cjs/link/persisted-queries/index.cjs +2 -2
  80. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  81. package/__cjs/link/persisted-queries/index.d.cts +2 -2
  82. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +2 -2
  83. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  84. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +1 -1
  85. package/__cjs/link/retry/delayFunction.cjs.map +1 -1
  86. package/__cjs/link/retry/delayFunction.d.cts +1 -1
  87. package/__cjs/link/retry/retryFunction.cjs.map +1 -1
  88. package/__cjs/link/retry/retryFunction.d.cts +1 -1
  89. package/__cjs/link/retry/retryLink.cjs +2 -2
  90. package/__cjs/link/retry/retryLink.cjs.map +1 -1
  91. package/__cjs/link/retry/retryLink.d.cts +2 -2
  92. package/__cjs/link/schema/index.cjs +2 -2
  93. package/__cjs/link/schema/index.cjs.map +1 -1
  94. package/__cjs/link/schema/index.d.cts +2 -2
  95. package/__cjs/link/subscriptions/index.cjs +2 -2
  96. package/__cjs/link/subscriptions/index.cjs.map +1 -1
  97. package/__cjs/link/subscriptions/index.d.cts +2 -2
  98. package/__cjs/link/utils/createOperation.cjs +5 -1
  99. package/__cjs/link/utils/createOperation.cjs.map +1 -1
  100. package/__cjs/link/utils/createOperation.d.cts +2 -2
  101. package/__cjs/link/utils/transformOperation.cjs.map +1 -1
  102. package/__cjs/link/utils/transformOperation.d.cts +1 -1
  103. package/__cjs/link/utils/validateOperation.cjs.map +1 -1
  104. package/__cjs/link/utils/validateOperation.d.cts +1 -1
  105. package/__cjs/link/ws/index.cjs +2 -2
  106. package/__cjs/link/ws/index.cjs.map +1 -1
  107. package/__cjs/link/ws/index.d.cts +2 -2
  108. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  109. package/__cjs/react/hooks/useMutation.d.cts +45 -12
  110. package/__cjs/react/index.cjs +3 -1
  111. package/__cjs/react/index.cjs.map +1 -1
  112. package/__cjs/react/index.d.cts +1 -0
  113. package/__cjs/react/types/deprecated.d.cts +3 -3
  114. package/__cjs/testing/core/mocking/mockLink.cjs +2 -2
  115. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  116. package/__cjs/testing/core/mocking/mockLink.d.cts +2 -2
  117. package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs +2 -2
  118. package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs.map +1 -1
  119. package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +2 -2
  120. package/__cjs/testing/internal/index.cjs +4 -1
  121. package/__cjs/testing/internal/index.cjs.map +1 -1
  122. package/__cjs/testing/internal/index.d.cts +1 -0
  123. package/__cjs/testing/internal/link.cjs +22 -0
  124. package/__cjs/testing/internal/link.cjs.map +1 -0
  125. package/__cjs/testing/internal/link.d.cts +6 -0
  126. package/__cjs/testing/matchers/isSameClient.cjs +19 -0
  127. package/__cjs/testing/matchers/isSameClient.cjs.map +1 -0
  128. package/__cjs/testing/matchers/isSameClient.d.cts +3 -0
  129. package/__cjs/testing/matchers/isSameObservableQuery.cjs +19 -0
  130. package/__cjs/testing/matchers/isSameObservableQuery.cjs.map +1 -0
  131. package/__cjs/testing/matchers/isSameObservableQuery.d.cts +3 -0
  132. package/__cjs/testing/matchers/toStrictEqualTyped.cjs +9 -3
  133. package/__cjs/testing/matchers/toStrictEqualTyped.cjs.map +1 -1
  134. package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +6 -1
  135. package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +3 -2
  136. package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -1
  137. package/__cjs/testing/matchers/utils/getSerializableProperties.d.cts +3 -1
  138. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  139. package/__cjs/testing/react/MockedProvider.d.cts +1 -1
  140. package/__cjs/utilities/common/errorHandling.cjs.map +1 -1
  141. package/__cjs/utilities/common/errorHandling.d.cts +1 -1
  142. package/__cjs/utilities/common/incrementalResult.cjs.map +1 -1
  143. package/__cjs/utilities/common/incrementalResult.d.cts +1 -1
  144. package/__cjs/utilities/common/mergeOptions.cjs.map +1 -1
  145. package/__cjs/utilities/common/mergeOptions.d.cts +2 -2
  146. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  147. package/__cjs/version.cjs +1 -1
  148. package/cache/core/cache.js +1 -1
  149. package/cache/inmemory/entityStore.js +3 -3
  150. package/cache/inmemory/key-extractor.js +1 -1
  151. package/cache/inmemory/policies.js +4 -4
  152. package/cache/inmemory/readFromStore.js +2 -2
  153. package/cache/inmemory/writeToStore.js +4 -4
  154. package/core/ApolloClient.d.ts +4 -21
  155. package/core/ApolloClient.js +18 -26
  156. package/core/ApolloClient.js.map +1 -1
  157. package/core/LocalState.d.ts +1 -2
  158. package/core/LocalState.js +2 -3
  159. package/core/LocalState.js.map +1 -1
  160. package/core/ObservableQuery.js +11 -11
  161. package/core/ObservableQuery.js.map +1 -1
  162. package/core/QueryInfo.d.ts +1 -1
  163. package/core/QueryInfo.js.map +1 -1
  164. package/core/QueryManager.d.ts +16 -18
  165. package/core/QueryManager.js +34 -33
  166. package/core/QueryManager.js.map +1 -1
  167. package/core/index.d.ts +4 -4
  168. package/core/index.js +1 -1
  169. package/core/index.js.map +1 -1
  170. package/core/types.d.ts +8 -3
  171. package/core/watchQueryOptions.d.ts +4 -4
  172. package/errors/index.d.ts +1 -1
  173. package/errors/index.js.map +1 -1
  174. package/invariantErrorCodes.js +47 -37
  175. package/legacyEntryPoints/link/index.d.ts +1 -0
  176. package/legacyEntryPoints/link/index.js +1 -0
  177. package/legacyEntryPoints/link/link.cjs +1 -0
  178. package/legacyEntryPoints/link/link.d.cts +1 -0
  179. package/link/batch/batchLink.d.ts +2 -2
  180. package/link/batch/batchLink.js +1 -1
  181. package/link/batch/batchLink.js.map +1 -1
  182. package/link/batch/batching.d.ts +1 -1
  183. package/link/batch/batching.js.map +1 -1
  184. package/link/batch-http/batchHttpLink.d.ts +5 -4
  185. package/link/batch-http/batchHttpLink.js +1 -1
  186. package/link/batch-http/batchHttpLink.js.map +1 -1
  187. package/link/context/index.d.ts +3 -4
  188. package/link/context/index.js +1 -1
  189. package/link/context/index.js.map +1 -1
  190. package/link/core/ApolloLink.d.ts +2 -2
  191. package/link/core/ApolloLink.js +2 -2
  192. package/link/core/ApolloLink.js.map +1 -1
  193. package/link/core/types.d.ts +19 -8
  194. package/link/error/index.d.ts +2 -2
  195. package/link/error/index.js +1 -1
  196. package/link/error/index.js.map +1 -1
  197. package/link/http/HttpLink.d.ts +129 -4
  198. package/link/http/HttpLink.js +1 -1
  199. package/link/http/HttpLink.js.map +1 -1
  200. package/link/http/createHttpLink.d.ts +3 -3
  201. package/link/http/createHttpLink.js +1 -1
  202. package/link/http/createHttpLink.js.map +1 -1
  203. package/link/http/index.d.ts +0 -1
  204. package/link/http/index.js.map +1 -1
  205. package/link/http/parseAndCheckHttpResponse.d.ts +1 -1
  206. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  207. package/link/http/rewriteURIForGET.d.ts +2 -2
  208. package/link/http/rewriteURIForGET.js.map +1 -1
  209. package/link/http/selectHttpOptionsAndBody.d.ts +8 -83
  210. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  211. package/link/http/selectURI.d.ts +1 -1
  212. package/link/http/selectURI.js.map +1 -1
  213. package/link/index.d.ts +8 -0
  214. package/link/index.js +7 -0
  215. package/link/index.js.map +1 -0
  216. package/link/persisted-queries/index.d.ts +2 -2
  217. package/link/persisted-queries/index.js +1 -1
  218. package/link/persisted-queries/index.js.map +1 -1
  219. package/link/remove-typename/removeTypenameFromVariables.d.ts +1 -1
  220. package/link/remove-typename/removeTypenameFromVariables.js +1 -1
  221. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  222. package/link/retry/delayFunction.d.ts +1 -1
  223. package/link/retry/delayFunction.js.map +1 -1
  224. package/link/retry/retryFunction.d.ts +1 -1
  225. package/link/retry/retryFunction.js.map +1 -1
  226. package/link/retry/retryLink.d.ts +2 -2
  227. package/link/retry/retryLink.js +1 -1
  228. package/link/retry/retryLink.js.map +1 -1
  229. package/link/schema/index.d.ts +2 -2
  230. package/link/schema/index.js +1 -1
  231. package/link/schema/index.js.map +1 -1
  232. package/link/subscriptions/index.d.ts +2 -2
  233. package/link/subscriptions/index.js +1 -1
  234. package/link/subscriptions/index.js.map +1 -1
  235. package/link/utils/createOperation.d.ts +2 -2
  236. package/link/utils/createOperation.js +5 -1
  237. package/link/utils/createOperation.js.map +1 -1
  238. package/link/utils/transformOperation.d.ts +1 -1
  239. package/link/utils/transformOperation.js.map +1 -1
  240. package/link/utils/validateOperation.d.ts +1 -1
  241. package/link/utils/validateOperation.js.map +1 -1
  242. package/link/ws/index.d.ts +2 -2
  243. package/link/ws/index.js +1 -1
  244. package/link/ws/index.js.map +1 -1
  245. package/package.json +12 -12
  246. package/react/hooks/useMutation.d.ts +45 -12
  247. package/react/hooks/useMutation.js.map +1 -1
  248. package/react/index.d.ts +1 -0
  249. package/react/index.js +1 -0
  250. package/react/index.js.map +1 -1
  251. package/react/types/deprecated.d.ts +3 -3
  252. package/testing/core/mocking/mockLink.d.ts +2 -2
  253. package/testing/core/mocking/mockLink.js +1 -1
  254. package/testing/core/mocking/mockLink.js.map +1 -1
  255. package/testing/core/mocking/mockSubscriptionLink.d.ts +2 -2
  256. package/testing/core/mocking/mockSubscriptionLink.js +1 -1
  257. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
  258. package/testing/internal/index.d.ts +1 -0
  259. package/testing/internal/index.js +1 -0
  260. package/testing/internal/index.js.map +1 -1
  261. package/testing/internal/link.d.ts +6 -0
  262. package/testing/internal/link.js +18 -0
  263. package/testing/internal/link.js.map +1 -0
  264. package/testing/matchers/isSameClient.d.ts +3 -0
  265. package/testing/matchers/isSameClient.js +15 -0
  266. package/testing/matchers/isSameClient.js.map +1 -0
  267. package/testing/matchers/isSameObservableQuery.d.ts +3 -0
  268. package/testing/matchers/isSameObservableQuery.js +15 -0
  269. package/testing/matchers/isSameObservableQuery.js.map +1 -0
  270. package/testing/matchers/toStrictEqualTyped.d.ts +6 -1
  271. package/testing/matchers/toStrictEqualTyped.js +9 -3
  272. package/testing/matchers/toStrictEqualTyped.js.map +1 -1
  273. package/testing/matchers/utils/getSerializableProperties.d.ts +3 -1
  274. package/testing/matchers/utils/getSerializableProperties.js +3 -2
  275. package/testing/matchers/utils/getSerializableProperties.js.map +1 -1
  276. package/testing/react/MockedProvider.d.ts +1 -1
  277. package/testing/react/MockedProvider.js.map +1 -1
  278. package/utilities/common/errorHandling.d.ts +1 -1
  279. package/utilities/common/errorHandling.js.map +1 -1
  280. package/utilities/common/incrementalResult.d.ts +1 -1
  281. package/utilities/common/incrementalResult.js.map +1 -1
  282. package/utilities/common/mergeOptions.d.ts +2 -2
  283. package/utilities/common/mergeOptions.js.map +1 -1
  284. package/utilities/subscriptions/relay/index.js.map +1 -1
  285. package/version.js +1 -1
  286. package/__cjs/link/core/index.cjs.map +0 -1
  287. package/__cjs/link/core/index.d.cts +0 -8
  288. package/legacyEntryPoints/link/core/core.cjs +0 -1
  289. package/legacyEntryPoints/link/core/core.d.cts +0 -1
  290. package/legacyEntryPoints/link/core/index.d.ts +0 -1
  291. package/legacyEntryPoints/link/core/index.js +0 -1
  292. package/link/core/index.d.ts +0 -8
  293. package/link/core/index.js +0 -7
  294. package/link/core/index.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Export `gql` from the `@apollo/client/react` entrypoint.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": major
3
+ ---
4
+
5
+ Remove the `typeDefs` option from `ApolloClient`.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": major
3
+ ---
4
+
5
+ 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.
@@ -0,0 +1,34 @@
1
+ ---
2
+ "@apollo/client": minor
3
+ ---
4
+
5
+ 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.
6
+
7
+ ```ts
8
+ // @apollo-client.d.ts
9
+ // This import is necessary to ensure all Apollo Client imports
10
+ // are still available to the rest of the application.
11
+ import '@apollo/client';
12
+
13
+ declare module "@apollo/client" {
14
+ interface DefaultContext extends Record<string, any> {
15
+ myProperty: string;
16
+ }
17
+ }
18
+ ```
19
+
20
+ 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:
21
+
22
+ ```ts
23
+ import { HttpLink } from "@apollo/client";
24
+
25
+ declare module "@apollo/client" {
26
+ interface DefaultContext extends HttpLink.ContextOptions {
27
+ myProperty: string;
28
+ }
29
+ }
30
+ ```
31
+
32
+ At this time, the following built-in links support context options:
33
+ - `HttpLink.ContextOptions`
34
+ - `BatchHttpLink.ContextOptions`
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ 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.
@@ -0,0 +1,12 @@
1
+ ---
2
+ "@apollo/client": major
3
+ ---
4
+
5
+ `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:
6
+
7
+ ```ts
8
+ ApolloLink.execute(link, operation, { client });
9
+
10
+ // or if you import the `execute` function directly:
11
+ execute(link, operation, { client });
12
+ ```
@@ -5,8 +5,10 @@
5
5
  "@apollo/client": "3.12.2"
6
6
  },
7
7
  "changesets": [
8
+ "afraid-grapes-call",
8
9
  "afraid-moons-arrive",
9
10
  "beige-mirrors-talk",
11
+ "brave-moons-juggle",
10
12
  "brave-radios-wait",
11
13
  "bright-ads-share",
12
14
  "calm-frogs-remain",
@@ -35,6 +37,7 @@
35
37
  "funny-terms-deny",
36
38
  "fuzzy-tips-sit",
37
39
  "gentle-badgers-train",
40
+ "gentle-waves-cough",
38
41
  "giant-apes-thank",
39
42
  "giant-bags-share",
40
43
  "good-dolphins-peel",
@@ -59,6 +62,7 @@
59
62
  "little-spoons-kick",
60
63
  "loud-cows-raise",
61
64
  "lucky-hats-push",
65
+ "lucky-sheep-explain",
62
66
  "many-buses-allow",
63
67
  "many-papayas-hide",
64
68
  "mean-lizards-think",
@@ -74,6 +78,8 @@
74
78
  "ninety-bags-bake",
75
79
  "odd-chicken-hide",
76
80
  "odd-lemons-relax",
81
+ "orange-suits-laugh",
82
+ "perfect-ducks-reflect",
77
83
  "perfect-vans-give",
78
84
  "polite-bees-care",
79
85
  "poor-eels-punch",
@@ -89,21 +95,26 @@
89
95
  "serious-moons-juggle",
90
96
  "seven-dragons-repair",
91
97
  "seven-foxes-melt",
98
+ "seven-schools-carry",
92
99
  "shaggy-pugs-add",
93
100
  "shiny-carrots-invent",
94
101
  "short-jokes-jam",
95
102
  "short-months-complain",
103
+ "short-tomatoes-attend",
96
104
  "silly-knives-exist",
105
+ "silly-seas-confess",
97
106
  "slimy-chicken-melt",
98
107
  "slimy-maps-press",
99
108
  "slow-ravens-explain",
100
109
  "small-buttons-rhyme",
101
110
  "small-cycles-rescue",
102
111
  "small-kids-film",
112
+ "small-poems-rest",
103
113
  "smart-rats-explode",
104
114
  "smooth-coins-collect",
105
115
  "smooth-pens-reply",
106
116
  "soft-mails-clean",
117
+ "sour-kids-deliver",
107
118
  "sour-pillows-guess",
108
119
  "strange-seahorses-impress",
109
120
  "swift-rivers-share",
@@ -125,6 +136,7 @@
125
136
  "unlucky-sheep-change",
126
137
  "warm-ties-sit",
127
138
  "wicked-forks-double",
139
+ "witty-paws-marry",
128
140
  "yellow-cats-judge",
129
141
  "young-phones-fold",
130
142
  "young-snails-grin",
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": minor
3
+ ---
4
+
5
+ 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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": major
3
+ ---
4
+
5
+ Remove `TContext` generic argument from all types that use it. `TContext` is replaced with `DefaultContext` which can be modified using declaration merging.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": major
3
+ ---
4
+
5
+ Drop `graphql` v15 as a valid peer dependency.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": major
3
+ ---
4
+
5
+ Don't `broadcastQueries` when a query is torn down.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": major
3
+ ---
4
+
5
+ Rename the `@apollo/client/link/core` entrypoint to `@apollo/client/link`.
@@ -0,0 +1,26 @@
1
+ ---
2
+ "@apollo/client": major
3
+ ---
4
+
5
+ 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:
6
+
7
+ **If using `uri`, `credentials`, or `headers` options**
8
+ ```diff
9
+ new ApolloClient({
10
+ // ...
11
+ - uri,
12
+ - credentials,
13
+ - headers,
14
+ + link: new HttpLink({ uri, credentials, headers }),
15
+ // or if you prefer the function call approach:
16
+ + link: createHttpLink({ uri, credentials, headers }),
17
+ });
18
+ ```
19
+
20
+ **If creating a client without the `link` option**
21
+ ```diff
22
+ new ApolloClient({
23
+ // ...
24
+ + link: ApolloLink.empty()
25
+ });
26
+ ```
package/CHANGELOG.md CHANGED
@@ -1,5 +1,101 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 4.0.0-alpha.12
4
+
5
+ ### Major Changes
6
+
7
+ - [#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`.
8
+
9
+ - [#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.
10
+
11
+ - [#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.
12
+
13
+ - [#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`.
14
+
15
+ - [#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:
16
+
17
+ **If using `uri`, `credentials`, or `headers` options**
18
+
19
+ ```diff
20
+ new ApolloClient({
21
+ // ...
22
+ - uri,
23
+ - credentials,
24
+ - headers,
25
+ + link: new HttpLink({ uri, credentials, headers }),
26
+ // or if you prefer the function call approach:
27
+ + link: createHttpLink({ uri, credentials, headers }),
28
+ });
29
+ ```
30
+
31
+ **If creating a client without the `link` option**
32
+
33
+ ```diff
34
+ new ApolloClient({
35
+ // ...
36
+ + link: ApolloLink.empty()
37
+ });
38
+ ```
39
+
40
+ ## 4.0.0-alpha.11
41
+
42
+ ### Major Changes
43
+
44
+ - [#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.
45
+
46
+ - [#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:
47
+
48
+ ```ts
49
+ ApolloLink.execute(link, operation, { client });
50
+
51
+ // or if you import the `execute` function directly:
52
+ execute(link, operation, { client });
53
+ ```
54
+
55
+ - [#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.
56
+
57
+ ### Minor Changes
58
+
59
+ - [#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.
60
+
61
+ ```ts
62
+ // @apollo-client.d.ts
63
+ // This import is necessary to ensure all Apollo Client imports
64
+ // are still available to the rest of the application.
65
+ import "@apollo/client";
66
+
67
+ declare module "@apollo/client" {
68
+ interface DefaultContext extends Record<string, any> {
69
+ myProperty: string;
70
+ }
71
+ }
72
+ ```
73
+
74
+ 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:
75
+
76
+ ```ts
77
+ import { HttpLink } from "@apollo/client";
78
+
79
+ declare module "@apollo/client" {
80
+ interface DefaultContext extends HttpLink.ContextOptions {
81
+ myProperty: string;
82
+ }
83
+ }
84
+ ```
85
+
86
+ At this time, the following built-in links support context options:
87
+
88
+ - `HttpLink.ContextOptions`
89
+ - `BatchHttpLink.ContextOptions`
90
+
91
+ - [#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.
92
+
93
+ ### Patch Changes
94
+
95
+ - [#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.
96
+
97
+ - [#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.
98
+
3
99
  ## 4.0.0-alpha.10
4
100
 
5
101
  ### Major Changes
@@ -94,7 +94,7 @@ class ApolloCache {
94
94
  if (environment_1.__DEV__) {
95
95
  const actualFragmentName = fragmentName || (0, utilities_1.getFragmentDefinition)(fragment).name.value;
96
96
  if (!id) {
97
- __DEV__ && invariant_1.invariant.warn(96, actualFragmentName);
97
+ __DEV__ && invariant_1.invariant.warn(97, actualFragmentName);
98
98
  }
99
99
  }
100
100
  const diffOptions = {
@@ -81,7 +81,7 @@ class EntityStore {
81
81
  // then there are no fields to be merged, so we're done.
82
82
  if (!incoming)
83
83
  return;
84
- (0, invariant_1.invariant)(typeof dataId === "string", 82);
84
+ (0, invariant_1.invariant)(typeof dataId === "string", 83);
85
85
  const merged = new utilities_1.DeepMerger(storeObjectReconciler).merge(existing, incoming);
86
86
  // Even if merged === existing, existing may have come from a lower
87
87
  // layer, so we always need to set this.data[dataId] on this level.
@@ -181,7 +181,7 @@ class EntityStore {
181
181
  if (environment_1.__DEV__) {
182
182
  const checkReference = (ref) => {
183
183
  if (this.lookup(ref.__ref) === undefined) {
184
- __DEV__ && invariant_1.invariant.warn(83, ref);
184
+ __DEV__ && invariant_1.invariant.warn(84, ref);
185
185
  return true;
186
186
  }
187
187
  };
@@ -210,7 +210,7 @@ class EntityStore {
210
210
  }
211
211
  }
212
212
  if (seenReference && someNonReference !== undefined) {
213
- __DEV__ && invariant_1.invariant.warn(84, someNonReference);
213
+ __DEV__ && invariant_1.invariant.warn(85, someNonReference);
214
214
  break;
215
215
  }
216
216
  }
@@ -41,7 +41,7 @@ function keyFieldsFnFromSpecifier(specifier) {
41
41
  // context.readField for this extraction.
42
42
  extracted = extractKeyPath(object, schemaKeyPath, extractKey);
43
43
  }
44
- (0, invariant_1.invariant)(extracted !== void 0, 85, schemaKeyPath.join("."), object);
44
+ (0, invariant_1.invariant)(extracted !== void 0, 86, schemaKeyPath.join("."), object);
45
45
  return extracted;
46
46
  }));
47
47
  return `${context.typename}:${JSON.stringify(keyObject)}`;
@@ -203,7 +203,7 @@ class Policies {
203
203
  const rootId = "ROOT_" + which.toUpperCase();
204
204
  const old = this.rootTypenamesById[rootId];
205
205
  if (typename !== old) {
206
- (0, invariant_1.invariant)(!old || old === which, 86, which);
206
+ (0, invariant_1.invariant)(!old || old === which, 87, which);
207
207
  // First, delete any old __typename associated with this rootId from
208
208
  // rootIdsByTypename.
209
209
  if (old)
@@ -348,7 +348,7 @@ class Policies {
348
348
  if (supertypeSet.has(supertype)) {
349
349
  if (!typenameSupertypeSet.has(supertype)) {
350
350
  if (checkingFuzzySubtypes) {
351
- __DEV__ && invariant_1.invariant.warn(87, typename, supertype);
351
+ __DEV__ && invariant_1.invariant.warn(88, typename, supertype);
352
352
  }
353
353
  // Record positive results for faster future lookup.
354
354
  // Unfortunately, we cannot safely cache negative results,
@@ -559,7 +559,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
559
559
  }
560
560
  }
561
561
  if (environment_1.__DEV__ && options.from === void 0) {
562
- __DEV__ && invariant_1.invariant.warn(88, (0, utilities_1.stringifyForDisplay)(Array.from(readFieldArgs)));
562
+ __DEV__ && invariant_1.invariant.warn(89, (0, utilities_1.stringifyForDisplay)(Array.from(readFieldArgs)));
563
563
  }
564
564
  if (void 0 === options.variables) {
565
565
  options.variables = variables;
@@ -569,7 +569,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
569
569
  function makeMergeObjectsFunction(store) {
570
570
  return function mergeObjects(existing, incoming) {
571
571
  if ((0, helpers_js_1.isArray)(existing) || (0, helpers_js_1.isArray)(incoming)) {
572
- throw (0, invariant_1.newInvariantError)(89);
572
+ throw (0, invariant_1.newInvariantError)(90);
573
573
  }
574
574
  // These dynamic checks are necessary because the parameters of a
575
575
  // custom merge function can easily have the any type, so the type
@@ -197,7 +197,7 @@ class StoreReader {
197
197
  else {
198
198
  const fragment = (0, utilities_1.getFragmentFromSelection)(selection, context.lookupFragment);
199
199
  if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
200
- throw (0, invariant_1.newInvariantError)(90, selection.name.value);
200
+ throw (0, invariant_1.newInvariantError)(91, selection.name.value);
201
201
  }
202
202
  if (fragment && policies.fragmentMatches(fragment, typename)) {
203
203
  fragment.selectionSet.selections.forEach(workSet.add, workSet);
@@ -281,7 +281,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
281
281
  if ((0, utilities_1.isNonNullObject)(value)) {
282
282
  (0, invariant_1.invariant)(
283
283
  !(0, utilities_1.isReference)(value),
284
- 91,
284
+ 92,
285
285
  (0, helpers_js_1.getTypenameFromStoreObject)(store, value),
286
286
  field.name.value
287
287
  );
@@ -72,7 +72,7 @@ class StoreWriter {
72
72
  context,
73
73
  });
74
74
  if (!(0, utilities_1.isReference)(ref)) {
75
- throw (0, invariant_1.newInvariantError)(92, result);
75
+ throw (0, invariant_1.newInvariantError)(93, result);
76
76
  }
77
77
  // So far, the store has not been modified, so now it's time to process
78
78
  // context.incomingById and merge those incoming fields into context.store.
@@ -222,7 +222,7 @@ class StoreWriter {
222
222
  // provide a default value, so its absence from the written data should
223
223
  // not be cause for alarm.
224
224
  !policies.getReadFunction(typename, field.name.value)) {
225
- __DEV__ && invariant_1.invariant.error(93, (0, utilities_1.resultKeyNameFromField)(field), result);
225
+ __DEV__ && invariant_1.invariant.error(94, (0, utilities_1.resultKeyNameFromField)(field), result);
226
226
  }
227
227
  });
228
228
  // Identify the result object, even if dataId was already provided,
@@ -369,7 +369,7 @@ class StoreWriter {
369
369
  else {
370
370
  const fragment = (0, utilities_1.getFragmentFromSelection)(selection, context.lookupFragment);
371
371
  if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
372
- throw (0, invariant_1.newInvariantError)(94, selection.name.value);
372
+ throw (0, invariant_1.newInvariantError)(95, selection.name.value);
373
373
  }
374
374
  if (fragment &&
375
375
  policies.fragmentMatches(fragment, typename, result, context.variables)) {
@@ -542,7 +542,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
542
542
  }
543
543
  });
544
544
  }
545
- __DEV__ && invariant_1.invariant.warn(95, fieldName, parentType, childTypenames.length ?
545
+ __DEV__ && invariant_1.invariant.warn(96, fieldName, parentType, childTypenames.length ?
546
546
  "either ensure all objects of type " +
547
547
  childTypenames.join(" and ") +
548
548
  " have an ID or a custom merge function, or "
@@ -7,8 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ApolloClient = exports.mergeOptions = void 0;
8
8
  const graphql_1 = require("graphql");
9
9
  const rxjs_1 = require("rxjs");
10
- const core_1 = require("@apollo/client/link/core");
11
- const http_1 = require("@apollo/client/link/http");
10
+ const link_1 = require("@apollo/client/link");
12
11
  const utilities_1 = require("@apollo/client/utilities");
13
12
  Object.defineProperty(exports, "mergeOptions", { enumerable: true, get: function () { return utilities_1.mergeOptions; } });
14
13
  const environment_1 = require("@apollo/client/utilities/environment");
@@ -47,7 +46,6 @@ class ApolloClient {
47
46
  version;
48
47
  queryDeduplication;
49
48
  defaultOptions;
50
- typeDefs;
51
49
  devtoolsConfig;
52
50
  queryManager;
53
51
  devToolsHookCb;
@@ -81,24 +79,19 @@ class ApolloClient {
81
79
  * ```
82
80
  */
83
81
  constructor(options) {
84
- if (!options.cache) {
85
- throw (0, invariant_1.newInvariantError)(58);
82
+ if (environment_1.__DEV__) {
83
+ (0, invariant_1.invariant)(options.cache, 58);
84
+ (0, invariant_1.invariant)(options.link, 59);
86
85
  }
87
- const { uri, credentials, headers, cache, documentTransform, ssrMode = false, ssrForceFetchDelay = 0,
86
+ const { cache, documentTransform, ssrMode = false, ssrForceFetchDelay = 0,
88
87
  // Expose the client instance as window.__APOLLO_CLIENT__ and call
89
88
  // onBroadcast in queryManager.broadcastQueries to enable browser
90
89
  // devtools, but disable them by default in production.
91
- connectToDevTools, queryDeduplication = true, defaultOptions, defaultContext, assumeImmutableResults = cache.assumeImmutableResults, resolvers, typeDefs, fragmentMatcher, name: clientAwarenessName, version: clientAwarenessVersion, devtools, dataMasking, } = options;
92
- let { link } = options;
93
- if (!link) {
94
- link =
95
- uri ? new http_1.HttpLink({ uri, credentials, headers }) : core_1.ApolloLink.empty();
96
- }
90
+ connectToDevTools, queryDeduplication = true, defaultOptions, defaultContext, assumeImmutableResults = cache.assumeImmutableResults, resolvers, fragmentMatcher, name: clientAwarenessName, version: clientAwarenessVersion, devtools, dataMasking, link, } = options;
97
91
  this.link = link;
98
92
  this.cache = cache;
99
93
  this.queryDeduplication = queryDeduplication;
100
94
  this.defaultOptions = defaultOptions || {};
101
- this.typeDefs = typeDefs;
102
95
  this.devtoolsConfig = {
103
96
  ...devtools,
104
97
  enabled: devtools?.enabled ?? connectToDevTools,
@@ -120,8 +113,7 @@ class ApolloClient {
120
113
  fragmentMatcher,
121
114
  });
122
115
  this.queryManager = new QueryManager_js_1.QueryManager({
123
- cache: this.cache,
124
- link: this.link,
116
+ client: this,
125
117
  defaultOptions: this.defaultOptions,
126
118
  defaultContext,
127
119
  documentTransform,
@@ -247,13 +239,13 @@ class ApolloClient {
247
239
  options = (0, utilities_1.mergeOptions)(this.defaultOptions.query, options);
248
240
  }
249
241
  if (environment_1.__DEV__) {
250
- (0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network", 59);
251
- (0, invariant_1.invariant)(options.fetchPolicy !== "standby", 60);
252
- (0, invariant_1.invariant)(options.query, 61);
253
- (0, invariant_1.invariant)(options.query.kind === "Document", 62);
254
- (0, invariant_1.invariant)(!options.returnPartialData, 63);
255
- (0, invariant_1.invariant)(!options.pollInterval, 64);
256
- (0, invariant_1.invariant)(!options.notifyOnNetworkStatusChange, 65);
242
+ (0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network", 60);
243
+ (0, invariant_1.invariant)(options.fetchPolicy !== "standby", 61);
244
+ (0, invariant_1.invariant)(options.query, 62);
245
+ (0, invariant_1.invariant)(options.query.kind === "Document", 63);
246
+ (0, invariant_1.invariant)(!options.returnPartialData, 64);
247
+ (0, invariant_1.invariant)(!options.pollInterval, 65);
248
+ (0, invariant_1.invariant)(!options.notifyOnNetworkStatusChange, 66);
257
249
  (0, utilities_1.checkDocument)(options.query, graphql_1.OperationTypeNode.QUERY);
258
250
  }
259
251
  return this.queryManager.query(options);
@@ -373,7 +365,7 @@ class ApolloClient {
373
365
  this.devToolsHookCb = cb;
374
366
  }
375
367
  __requestRaw(payload) {
376
- return (0, core_1.execute)(this.link, payload);
368
+ return (0, link_1.execute)(this.link, payload, { client: this });
377
369
  }
378
370
  /**
379
371
  * Resets your entire store by clearing out your cache and then re-executing
@@ -475,7 +467,7 @@ class ApolloClient {
475
467
  // result.queries and result.results instead, you shouldn't have to worry
476
468
  // about preventing uncaught rejections for the Promise.all result.
477
469
  result.catch((error) => {
478
- __DEV__ && invariant_1.invariant.debug(66, error);
470
+ __DEV__ && invariant_1.invariant.debug(67, error);
479
471
  });
480
472
  return result;
481
473
  }
@@ -537,7 +529,7 @@ class ApolloClient {
537
529
  * Define a new ApolloLink (or link chain) that Apollo Client will use.
538
530
  */
539
531
  setLink(newLink) {
540
- this.link = this.queryManager.link = newLink;
532
+ this.link = newLink;
541
533
  }
542
534
  get defaultContext() {
543
535
  return this.queryManager.defaultContext;