@apollo/client 3.4.9 → 3.4.13

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 (247) hide show
  1. package/README.md +2 -2
  2. package/apollo-client.cjs.js +58 -67
  3. package/apollo-client.cjs.js.map +1 -1
  4. package/apollo-client.cjs.min.js +1 -0
  5. package/cache/cache.cjs.js +20 -22
  6. package/cache/cache.cjs.js.map +1 -1
  7. package/cache/core/cache.js.map +1 -1
  8. package/cache/index.d.ts +1 -0
  9. package/cache/index.d.ts.map +1 -1
  10. package/cache/index.js +1 -2
  11. package/cache/index.js.map +1 -1
  12. package/cache/inmemory/entityStore.js +1 -1
  13. package/cache/inmemory/entityStore.js.map +1 -1
  14. package/cache/inmemory/object-canon.d.ts +1 -0
  15. package/cache/inmemory/object-canon.d.ts.map +1 -1
  16. package/cache/inmemory/object-canon.js +1 -0
  17. package/cache/inmemory/object-canon.js.map +1 -1
  18. package/cache/inmemory/policies.d.ts.map +1 -1
  19. package/cache/inmemory/policies.js +1 -1
  20. package/cache/inmemory/policies.js.map +1 -1
  21. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  22. package/cache/inmemory/readFromStore.js +1 -1
  23. package/cache/inmemory/readFromStore.js.map +1 -1
  24. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  25. package/cache/inmemory/writeToStore.js +1 -1
  26. package/cache/inmemory/writeToStore.js.map +1 -1
  27. package/core/ApolloClient.d.ts.map +1 -1
  28. package/core/ApolloClient.js +1 -1
  29. package/core/ApolloClient.js.map +1 -1
  30. package/core/LocalState.d.ts.map +1 -1
  31. package/core/LocalState.js +1 -1
  32. package/core/LocalState.js.map +1 -1
  33. package/core/ObservableQuery.d.ts.map +1 -1
  34. package/core/ObservableQuery.js +18 -5
  35. package/core/ObservableQuery.js.map +1 -1
  36. package/core/QueryManager.d.ts.map +1 -1
  37. package/core/QueryManager.js +1 -1
  38. package/core/QueryManager.js.map +1 -1
  39. package/core/core.cjs.js +47 -34
  40. package/core/core.cjs.js.map +1 -1
  41. package/core/index.d.ts.map +1 -1
  42. package/core/index.js +1 -2
  43. package/core/index.js.map +1 -1
  44. package/core/watchQueryOptions.js.map +1 -1
  45. package/errors/errors.cjs.js +1 -1
  46. package/errors/errors.cjs.js.map +1 -1
  47. package/errors/index.d.ts +1 -0
  48. package/errors/index.d.ts.map +1 -1
  49. package/errors/index.js +1 -2
  50. package/errors/index.js.map +1 -1
  51. package/invariantErrorCodes.js +1 -1
  52. package/link/core/ApolloLink.js +1 -1
  53. package/link/core/ApolloLink.js.map +1 -1
  54. package/link/core/core.cjs.js +4 -6
  55. package/link/core/core.cjs.js.map +1 -1
  56. package/link/core/index.d.ts +1 -0
  57. package/link/core/index.d.ts.map +1 -1
  58. package/link/core/index.js +1 -2
  59. package/link/core/index.js.map +1 -1
  60. package/link/http/checkFetcher.js +1 -1
  61. package/link/http/checkFetcher.js.map +1 -1
  62. package/link/http/createHttpLink.d.ts +1 -0
  63. package/link/http/createHttpLink.d.ts.map +1 -1
  64. package/link/http/createHttpLink.js +1 -0
  65. package/link/http/createHttpLink.js.map +1 -1
  66. package/link/http/http.cjs.js +4 -6
  67. package/link/http/http.cjs.js.map +1 -1
  68. package/link/http/index.d.ts +1 -0
  69. package/link/http/index.d.ts.map +1 -1
  70. package/link/http/index.js +1 -2
  71. package/link/http/index.js.map +1 -1
  72. package/link/http/serializeFetchParameter.d.ts +1 -1
  73. package/link/http/serializeFetchParameter.d.ts.map +1 -1
  74. package/link/http/serializeFetchParameter.js +1 -1
  75. package/link/http/serializeFetchParameter.js.map +1 -1
  76. package/link/persisted-queries/index.d.ts +1 -1
  77. package/link/persisted-queries/index.d.ts.map +1 -1
  78. package/link/persisted-queries/index.js +2 -4
  79. package/link/persisted-queries/index.js.map +1 -1
  80. package/link/persisted-queries/persisted-queries.cjs.js +8 -6
  81. package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
  82. package/link/utils/index.d.ts +1 -0
  83. package/link/utils/index.d.ts.map +1 -1
  84. package/link/utils/index.js +1 -2
  85. package/link/utils/index.js.map +1 -1
  86. package/link/utils/toPromise.d.ts.map +1 -1
  87. package/link/utils/toPromise.js +1 -1
  88. package/link/utils/toPromise.js.map +1 -1
  89. package/link/utils/utils.cjs.js +3 -5
  90. package/link/utils/utils.cjs.js.map +1 -1
  91. package/link/utils/validateOperation.d.ts.map +1 -1
  92. package/link/utils/validateOperation.js +1 -1
  93. package/link/utils/validateOperation.js.map +1 -1
  94. package/package.json +11 -11
  95. package/react/context/ApolloConsumer.d.ts.map +1 -1
  96. package/react/context/ApolloConsumer.js +1 -1
  97. package/react/context/ApolloConsumer.js.map +1 -1
  98. package/react/context/ApolloContext.d.ts +2 -1
  99. package/react/context/ApolloContext.d.ts.map +1 -1
  100. package/react/context/ApolloContext.js +11 -5
  101. package/react/context/ApolloContext.js.map +1 -1
  102. package/react/context/ApolloProvider.d.ts.map +1 -1
  103. package/react/context/ApolloProvider.js +1 -1
  104. package/react/context/ApolloProvider.js.map +1 -1
  105. package/react/context/context.cjs.js +16 -12
  106. package/react/context/context.cjs.js.map +1 -1
  107. package/react/context/index.d.ts +1 -0
  108. package/react/context/index.d.ts.map +1 -1
  109. package/react/context/index.js +1 -2
  110. package/react/context/index.js.map +1 -1
  111. package/react/data/OperationData.d.ts.map +1 -1
  112. package/react/data/OperationData.js +1 -1
  113. package/react/data/OperationData.js.map +1 -1
  114. package/react/data/QueryData.d.ts.map +1 -1
  115. package/react/data/QueryData.js +1 -3
  116. package/react/data/QueryData.js.map +1 -1
  117. package/react/data/data.cjs.js +6 -11
  118. package/react/data/data.cjs.js.map +1 -1
  119. package/react/data/index.d.ts +1 -0
  120. package/react/data/index.d.ts.map +1 -1
  121. package/react/data/index.js +1 -2
  122. package/react/data/index.js.map +1 -1
  123. package/react/hoc/hoc-utils.d.ts.map +1 -1
  124. package/react/hoc/hoc-utils.js +1 -1
  125. package/react/hoc/hoc-utils.js.map +1 -1
  126. package/react/hoc/hoc.cjs.js +13 -13
  127. package/react/hoc/hoc.cjs.js.map +1 -1
  128. package/react/hoc/index.d.ts +1 -0
  129. package/react/hoc/index.d.ts.map +1 -1
  130. package/react/hoc/index.js +1 -2
  131. package/react/hoc/index.js.map +1 -1
  132. package/react/hoc/subscription-hoc.d.ts.map +1 -1
  133. package/react/hoc/subscription-hoc.js +8 -5
  134. package/react/hoc/subscription-hoc.js.map +1 -1
  135. package/react/hoc/withApollo.d.ts.map +1 -1
  136. package/react/hoc/withApollo.js +1 -1
  137. package/react/hoc/withApollo.js.map +1 -1
  138. package/react/hooks/hooks.cjs.js +3 -6
  139. package/react/hooks/hooks.cjs.js.map +1 -1
  140. package/react/hooks/index.d.ts +1 -0
  141. package/react/hooks/index.d.ts.map +1 -1
  142. package/react/hooks/index.js +1 -2
  143. package/react/hooks/index.js.map +1 -1
  144. package/react/hooks/useApolloClient.d.ts.map +1 -1
  145. package/react/hooks/useApolloClient.js +1 -1
  146. package/react/hooks/useApolloClient.js.map +1 -1
  147. package/react/hooks/useSubscription.d.ts +1 -0
  148. package/react/hooks/useSubscription.d.ts.map +1 -1
  149. package/react/hooks/useSubscription.js +1 -0
  150. package/react/hooks/useSubscription.js.map +1 -1
  151. package/react/hooks/utils/useAfterFastRefresh.d.ts +1 -0
  152. package/react/hooks/utils/useAfterFastRefresh.d.ts.map +1 -1
  153. package/react/hooks/utils/useAfterFastRefresh.js +1 -0
  154. package/react/hooks/utils/useAfterFastRefresh.js.map +1 -1
  155. package/react/hooks/utils/useBaseQuery.d.ts +1 -0
  156. package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
  157. package/react/hooks/utils/useBaseQuery.js +1 -0
  158. package/react/hooks/utils/useBaseQuery.js.map +1 -1
  159. package/react/index.d.ts +1 -0
  160. package/react/index.d.ts.map +1 -1
  161. package/react/index.js +1 -2
  162. package/react/index.js.map +1 -1
  163. package/react/parser/index.d.ts.map +1 -1
  164. package/react/parser/index.js +1 -3
  165. package/react/parser/index.js.map +1 -1
  166. package/react/parser/parser.cjs.js +9 -11
  167. package/react/parser/parser.cjs.js.map +1 -1
  168. package/react/react.cjs.js +2 -2
  169. package/react/react.cjs.js.map +1 -1
  170. package/testing/index.d.ts +1 -0
  171. package/testing/index.d.ts.map +1 -1
  172. package/testing/index.js +1 -2
  173. package/testing/index.js.map +1 -1
  174. package/testing/testing.cjs.js +3 -5
  175. package/testing/testing.cjs.js.map +1 -1
  176. package/utilities/common/canUse.d.ts +1 -0
  177. package/utilities/common/canUse.d.ts.map +1 -1
  178. package/utilities/common/canUse.js +2 -0
  179. package/utilities/common/canUse.js.map +1 -1
  180. package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
  181. package/utilities/common/maybeDeepFreeze.js +14 -3
  182. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  183. package/utilities/common/mergeDeep.js +1 -1
  184. package/utilities/common/mergeDeep.js.map +1 -1
  185. package/utilities/globals/DEV.js +2 -2
  186. package/utilities/globals/DEV.js.map +1 -1
  187. package/utilities/{common → globals}/global.d.ts +0 -0
  188. package/utilities/globals/global.d.ts.map +1 -0
  189. package/utilities/{common → globals}/global.js +0 -0
  190. package/utilities/globals/global.js.map +1 -0
  191. package/utilities/globals/globals.cjs.js +57 -0
  192. package/utilities/globals/globals.cjs.js.map +1 -0
  193. package/utilities/globals/index.d.ts +4 -2
  194. package/utilities/globals/index.d.ts.map +1 -1
  195. package/utilities/globals/index.js +5 -2
  196. package/utilities/globals/index.js.map +1 -1
  197. package/utilities/{common → globals}/maybe.d.ts +0 -0
  198. package/utilities/globals/maybe.d.ts.map +1 -0
  199. package/utilities/{common → globals}/maybe.js +0 -0
  200. package/utilities/globals/maybe.js.map +1 -0
  201. package/utilities/globals/package.json +7 -0
  202. package/utilities/graphql/directives.d.ts.map +1 -1
  203. package/utilities/graphql/directives.js +1 -1
  204. package/utilities/graphql/directives.js.map +1 -1
  205. package/utilities/graphql/fragments.d.ts.map +1 -1
  206. package/utilities/graphql/fragments.js +2 -2
  207. package/utilities/graphql/fragments.js.map +1 -1
  208. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  209. package/utilities/graphql/getFromAST.js +1 -1
  210. package/utilities/graphql/getFromAST.js.map +1 -1
  211. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  212. package/utilities/graphql/storeUtils.js +1 -1
  213. package/utilities/graphql/storeUtils.js.map +1 -1
  214. package/utilities/graphql/transform.d.ts.map +1 -1
  215. package/utilities/graphql/transform.js +2 -2
  216. package/utilities/graphql/transform.js.map +1 -1
  217. package/utilities/index.d.ts +1 -3
  218. package/utilities/index.d.ts.map +1 -1
  219. package/utilities/index.js +1 -4
  220. package/utilities/index.js.map +1 -1
  221. package/utilities/observables/subclassing.d.ts.map +1 -1
  222. package/utilities/observables/subclassing.js +2 -1
  223. package/utilities/observables/subclassing.js.map +1 -1
  224. package/utilities/package.json +1 -3
  225. package/utilities/policies/pagination.d.ts +1 -1
  226. package/utilities/policies/pagination.d.ts.map +1 -1
  227. package/utilities/policies/pagination.js +9 -4
  228. package/utilities/policies/pagination.js.map +1 -1
  229. package/utilities/testing/mocking/mockFetch.js +1 -1
  230. package/utilities/testing/mocking/mockFetch.js.map +1 -1
  231. package/utilities/testing/mocking/mockLink.d.ts.map +1 -1
  232. package/utilities/testing/mocking/mockLink.js +1 -1
  233. package/utilities/testing/mocking/mockLink.js.map +1 -1
  234. package/utilities/testing/mocking/mockWatchQuery.js +1 -1
  235. package/utilities/testing/mocking/mockWatchQuery.js.map +1 -1
  236. package/utilities/testing/observableToPromise.js +1 -1
  237. package/utilities/testing/observableToPromise.js.map +1 -1
  238. package/utilities/utilities.cjs.js +57 -83
  239. package/utilities/utilities.cjs.js.map +1 -1
  240. package/version.js +1 -1
  241. package/apollo-core.cjs.js +0 -5772
  242. package/apollo-core.cjs.js.map +0 -1
  243. package/apollo-core.cjs.min.js +0 -1
  244. package/utilities/common/global.d.ts.map +0 -1
  245. package/utilities/common/global.js.map +0 -1
  246. package/utilities/common/maybe.d.ts.map +0 -1
  247. package/utilities/common/maybe.js.map +0 -1
package/README.md CHANGED
@@ -22,9 +22,9 @@ Learn how to use Apollo Client with self-paced hands-on training on Odyssey, Apo
22
22
  ## Maintainers
23
23
 
24
24
  - [@benjamn](https://github.com/benjamn) (Apollo)
25
- - [@hwillson](https://github.com/hwillson) (Apollo)
26
- - [@jcreighton](https://github.com/jcreighton) (Apollo)
27
25
  - [@brainkim](https://github.com/brainkim) (Apollo)
26
+ - [@jcreighton](https://github.com/jcreighton) (Netflix)
27
+ - [@hwillson](https://github.com/hwillson) (Apollo)
28
28
 
29
29
  ## Who is Apollo?
30
30
 
@@ -5,10 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib = require('tslib');
6
6
  var tsInvariant = require('ts-invariant');
7
7
  var equality = require('@wry/equality');
8
- var process$1 = require('ts-invariant/process');
9
- var graphql = require('graphql');
10
8
  var zenObservableTs = require('zen-observable-ts');
11
9
  require('symbol-observable');
10
+ var graphql = require('graphql');
12
11
  var optimism = require('optimism');
13
12
  var context = require('@wry/context');
14
13
  var trie = require('@wry/trie');
@@ -36,40 +35,6 @@ function maybe(thunk) {
36
35
  catch (_a) { }
37
36
  }
38
37
 
39
- var global$1 = (maybe(function () { return globalThis; }) ||
40
- maybe(function () { return window; }) ||
41
- maybe(function () { return self; }) ||
42
- maybe(function () { return global; }) ||
43
- maybe(function () { return Function("return this")(); }));
44
-
45
- var __ = "__";
46
- var GLOBAL_KEY = [__, __].join("DEV");
47
- function getDEV() {
48
- try {
49
- return Boolean(__DEV__);
50
- }
51
- catch (_a) {
52
- Object.defineProperty(global$1, GLOBAL_KEY, {
53
- value: maybe(function () { return process.env.NODE_ENV; }) !== "production",
54
- enumerable: false,
55
- configurable: true,
56
- writable: true,
57
- });
58
- return global$1[GLOBAL_KEY];
59
- }
60
- }
61
- var DEV = getDEV();
62
-
63
- function removeTemporaryGlobals() {
64
- graphql.isType(null);
65
- return process$1.remove();
66
- }
67
-
68
- function checkDEV() {
69
- __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 38);
70
- }
71
- removeTemporaryGlobals();
72
-
73
38
  function shouldInclude(_a, variables) {
74
39
  var directives = _a.directives;
75
40
  if (!directives || !directives.length) {
@@ -163,7 +128,7 @@ function getFragmentQueryDocument(document, fragmentName) {
163
128
  ],
164
129
  },
165
130
  }
166
- ], document.definitions) });
131
+ ], document.definitions, true) });
167
132
  return query;
168
133
  }
169
134
  function createFragmentMap(fragments) {
@@ -599,7 +564,7 @@ var addTypenameToDocument = Object.assign(function (doc) {
599
564
  field.directives.some(function (d) { return d.name.value === 'export'; })) {
600
565
  return;
601
566
  }
602
- return tslib.__assign(tslib.__assign({}, node), { selections: tslib.__spreadArray(tslib.__spreadArray([], selections), [TYPENAME_FIELD]) });
567
+ return tslib.__assign(tslib.__assign({}, node), { selections: tslib.__spreadArray(tslib.__spreadArray([], selections, true), [TYPENAME_FIELD], false) });
603
568
  },
604
569
  },
605
570
  });
@@ -738,7 +703,7 @@ function removeClientSetsFromDocument(document) {
738
703
  return modifiedDoc;
739
704
  }
740
705
 
741
- var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
706
+ var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
742
707
  function mergeDeep() {
743
708
  var sources = [];
744
709
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -775,10 +740,10 @@ var DeepMerger = (function () {
775
740
  }
776
741
  if (isNonNullObject(source) && isNonNullObject(target)) {
777
742
  Object.keys(source).forEach(function (sourceKey) {
778
- if (hasOwnProperty$2.call(target, sourceKey)) {
743
+ if (hasOwnProperty$3.call(target, sourceKey)) {
779
744
  var targetValue = target[sourceKey];
780
745
  if (source[sourceKey] !== targetValue) {
781
- var result = _this.reconciler.apply(_this, tslib.__spreadArray([target, source, sourceKey], context));
746
+ var result = _this.reconciler.apply(_this, tslib.__spreadArray([target, source, sourceKey], context, false));
782
747
  if (result !== targetValue) {
783
748
  target = _this.shallowCopyForMerge(target);
784
749
  target[sourceKey] = result;
@@ -845,9 +810,7 @@ function cloneDeepHelper(val, seen) {
845
810
  function deepFreeze(value) {
846
811
  var workSet = new Set([value]);
847
812
  workSet.forEach(function (obj) {
848
- if (isNonNullObject(obj)) {
849
- if (!Object.isFrozen(obj))
850
- Object.freeze(obj);
813
+ if (isNonNullObject(obj) && shallowFreeze(obj) === obj) {
851
814
  Object.getOwnPropertyNames(obj).forEach(function (name) {
852
815
  if (isNonNullObject(obj[name]))
853
816
  workSet.add(obj[name]);
@@ -856,6 +819,19 @@ function deepFreeze(value) {
856
819
  });
857
820
  return value;
858
821
  }
822
+ function shallowFreeze(obj) {
823
+ if (__DEV__ && !Object.isFrozen(obj)) {
824
+ try {
825
+ Object.freeze(obj);
826
+ }
827
+ catch (e) {
828
+ if (e instanceof TypeError)
829
+ return null;
830
+ throw e;
831
+ }
832
+ }
833
+ return obj;
834
+ }
859
835
  function maybeDeepFreeze(obj) {
860
836
  if (__DEV__) {
861
837
  deepFreeze(obj);
@@ -917,11 +893,17 @@ function asyncMap(observable, mapFn, catchFn) {
917
893
  });
918
894
  }
919
895
 
896
+ var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
897
+ navigator.product === 'ReactNative');
898
+ var canUseWeakSet = typeof WeakSet === 'function';
899
+ var canUseSymbol = typeof Symbol === 'function' &&
900
+ typeof Symbol.for === 'function';
901
+
920
902
  function fixObservableSubclass(subclass) {
921
903
  function set(key) {
922
904
  Object.defineProperty(subclass, key, { value: zenObservableTs.Observable });
923
905
  }
924
- if (typeof Symbol === "function" && Symbol.species) {
906
+ if (canUseSymbol && Symbol.species) {
925
907
  set(Symbol.species);
926
908
  }
927
909
  set("@@species");
@@ -1067,10 +1049,6 @@ function graphQLResultHasError(result) {
1067
1049
  return (result.errors && result.errors.length > 0) || false;
1068
1050
  }
1069
1051
 
1070
- var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
1071
- navigator.product === 'ReactNative');
1072
- var canUseWeakSet = typeof WeakSet === 'function';
1073
-
1074
1052
  function compact() {
1075
1053
  var objects = [];
1076
1054
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1104,8 +1082,6 @@ function stringifyForDisplay(value) {
1104
1082
  }).split(JSON.stringify(undefId)).join("<undefined>");
1105
1083
  }
1106
1084
 
1107
- checkDEV();
1108
-
1109
1085
  function fromError(errorValue) {
1110
1086
  return new zenObservableTs.Observable(function (observer) {
1111
1087
  observer.error(errorValue);
@@ -1310,9 +1286,9 @@ var concat = ApolloLink.concat;
1310
1286
 
1311
1287
  var execute = ApolloLink.execute;
1312
1288
 
1313
- var version = '3.4.9';
1289
+ var version = '3.4.13';
1314
1290
 
1315
- var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1291
+ var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1316
1292
  function parseAndCheckHttpResponse(operations) {
1317
1293
  return function (response) { return response
1318
1294
  .text()
@@ -1334,8 +1310,8 @@ function parseAndCheckHttpResponse(operations) {
1334
1310
  throwServerError(response, result, "Response not successful: Received status code " + response.status);
1335
1311
  }
1336
1312
  if (!Array.isArray(result) &&
1337
- !hasOwnProperty$1.call(result, 'data') &&
1338
- !hasOwnProperty$1.call(result, 'errors')) {
1313
+ !hasOwnProperty$2.call(result, 'data') &&
1314
+ !hasOwnProperty$2.call(result, 'errors')) {
1339
1315
  throwServerError(response, result, "Server response was missing for query '" + (Array.isArray(operations)
1340
1316
  ? operations.map(function (op) { return op.operationName; })
1341
1317
  : operations.operationName) + "'.");
@@ -3690,7 +3666,6 @@ var InMemoryCache = (function (_super) {
3690
3666
  return InMemoryCache;
3691
3667
  }(ApolloCache));
3692
3668
 
3693
- checkDEV();
3694
3669
  function isApolloError(err) {
3695
3670
  return err.hasOwnProperty('graphQLErrors');
3696
3671
  }
@@ -3742,6 +3717,7 @@ function isNetworkRequestInFlight(networkStatus) {
3742
3717
  return networkStatus ? networkStatus < 7 : false;
3743
3718
  }
3744
3719
 
3720
+ var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
3745
3721
  var warnedAboutUpdateQuery = false;
3746
3722
  var ObservableQuery = (function (_super) {
3747
3723
  tslib.__extends(ObservableQuery, _super);
@@ -3818,7 +3794,12 @@ var ObservableQuery = (function (_super) {
3818
3794
  (lastResult && lastResult.networkStatus) ||
3819
3795
  exports.NetworkStatus.ready;
3820
3796
  var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
3821
- if (!this.queryManager.transform(this.options.query).hasForcedResolvers) {
3797
+ var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
3798
+ var shouldReturnCachedData = lastResult || (fetchPolicy !== 'network-only' &&
3799
+ fetchPolicy !== 'no-cache' &&
3800
+ fetchPolicy !== 'standby');
3801
+ if (shouldReturnCachedData &&
3802
+ !this.queryManager.transform(this.options.query).hasForcedResolvers) {
3822
3803
  var diff = this.queryInfo.getDiff();
3823
3804
  if (diff.complete || this.options.returnPartialData) {
3824
3805
  result.data = diff.result;
@@ -3826,7 +3807,6 @@ var ObservableQuery = (function (_super) {
3826
3807
  if (equality.equal(result.data, {})) {
3827
3808
  result.data = void 0;
3828
3809
  }
3829
- var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
3830
3810
  if (diff.complete) {
3831
3811
  if (result.networkStatus === exports.NetworkStatus.loading &&
3832
3812
  (fetchPolicy === 'cache-first' ||
@@ -3878,6 +3858,7 @@ var ObservableQuery = (function (_super) {
3878
3858
  this.queryManager.resetErrors(this.queryId);
3879
3859
  };
3880
3860
  ObservableQuery.prototype.refetch = function (variables) {
3861
+ var _a;
3881
3862
  var reobserveOptions = {
3882
3863
  pollInterval: 0,
3883
3864
  };
@@ -3888,6 +3869,13 @@ var ObservableQuery = (function (_super) {
3888
3869
  else if (fetchPolicy !== 'cache-and-network') {
3889
3870
  reobserveOptions.fetchPolicy = 'network-only';
3890
3871
  }
3872
+ if (__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
3873
+ var queryDef = getQueryDefinition(this.options.query);
3874
+ var vars = queryDef.variableDefinitions;
3875
+ if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
3876
+ __DEV__ && tsInvariant.invariant.warn("Called refetch(" + JSON.stringify(variables) + ") for query " + (((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef)) + ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?");
3877
+ }
3878
+ }
3891
3879
  if (variables && !equality.equal(this.options.variables, variables)) {
3892
3880
  reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
3893
3881
  }
@@ -4075,7 +4063,7 @@ var ObservableQuery = (function (_super) {
4075
4063
  var oldVariables = this.options.variables;
4076
4064
  var options = useDisposableConcast
4077
4065
  ? compact(this.options, newOptions)
4078
- : Object.assign(this.options, compact(newOptions));
4066
+ : assign(this.options, compact(newOptions));
4079
4067
  if (!useDisposableConcast) {
4080
4068
  this.updatePolling();
4081
4069
  if (newOptions &&
@@ -5741,13 +5729,19 @@ var ApolloClient = (function () {
5741
5729
  return ApolloClient;
5742
5730
  }());
5743
5731
 
5744
- var cache$1 = new (canUseWeakMap ? WeakMap : Map)();
5732
+ var contextKey = canUseSymbol
5733
+ ? Symbol.for('__APOLLO_CONTEXT__')
5734
+ : '__APOLLO_CONTEXT__';
5745
5735
  function getApolloContext() {
5746
- var context = cache$1.get(React__namespace.createContext);
5736
+ var context = React__namespace.createContext[contextKey];
5747
5737
  if (!context) {
5748
- context = React__namespace.createContext({});
5738
+ Object.defineProperty(React__namespace.createContext, contextKey, {
5739
+ value: context = React__namespace.createContext({}),
5740
+ enumerable: false,
5741
+ writable: false,
5742
+ configurable: true,
5743
+ });
5749
5744
  context.displayName = 'ApolloContext';
5750
- cache$1.set(React__namespace.createContext, context);
5751
5745
  }
5752
5746
  return context;
5753
5747
  }
@@ -5782,7 +5776,6 @@ function useApolloClient() {
5782
5776
  return client;
5783
5777
  }
5784
5778
 
5785
- checkDEV();
5786
5779
  exports.DocumentType = void 0;
5787
5780
  (function (DocumentType) {
5788
5781
  DocumentType[DocumentType["Query"] = 0] = "Query";
@@ -6193,9 +6186,7 @@ var QueryData = (function (_super) {
6193
6186
  var _b = _a === void 0 ? {} : _a, _c = _b.lazy, lazy = _c === void 0 ? false : _c;
6194
6187
  this.isMounted = true;
6195
6188
  var options = this.getOptions();
6196
- if (this.currentObservable &&
6197
- !this.ssrInitiated() &&
6198
- !this.client.disableNetworkFetches) {
6189
+ if (this.currentObservable && !this.ssrInitiated()) {
6199
6190
  this.startQuerySubscription();
6200
6191
  }
6201
6192
  if (!lazy || this.runLazy) {