@apollo/client 3.4.6 → 3.4.10

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 (216) hide show
  1. package/apollo-client.cjs.js +155 -156
  2. package/apollo-client.cjs.js.map +1 -1
  3. package/apollo-core.cjs.js +136 -103
  4. package/apollo-core.cjs.js.map +1 -1
  5. package/apollo-core.cjs.min.js +1 -1
  6. package/cache/cache.cjs.js +32 -31
  7. package/cache/cache.cjs.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 -3
  11. package/cache/index.js.map +1 -1
  12. package/cache/inmemory/entityStore.js +2 -2
  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 +13 -10
  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 +4 -4
  23. package/cache/inmemory/readFromStore.js.map +1 -1
  24. package/cache/inmemory/writeToStore.d.ts +1 -1
  25. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  26. package/cache/inmemory/writeToStore.js +5 -5
  27. package/cache/inmemory/writeToStore.js.map +1 -1
  28. package/core/ApolloClient.d.ts.map +1 -1
  29. package/core/ApolloClient.js +3 -3
  30. package/core/ApolloClient.js.map +1 -1
  31. package/core/LocalState.d.ts.map +1 -1
  32. package/core/LocalState.js +2 -2
  33. package/core/LocalState.js.map +1 -1
  34. package/core/ObservableQuery.d.ts +7 -6
  35. package/core/ObservableQuery.d.ts.map +1 -1
  36. package/core/ObservableQuery.js +79 -46
  37. package/core/ObservableQuery.js.map +1 -1
  38. package/core/QueryManager.d.ts.map +1 -1
  39. package/core/QueryManager.js +10 -10
  40. package/core/QueryManager.js.map +1 -1
  41. package/core/core.cjs.js +109 -75
  42. package/core/core.cjs.js.map +1 -1
  43. package/core/index.js +1 -1
  44. package/core/index.js.map +1 -1
  45. package/errors/errors.cjs.js +1 -2
  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 -3
  50. package/errors/index.js.map +1 -1
  51. package/invariantErrorCodes.js +56 -81
  52. package/link/core/ApolloLink.js +2 -2
  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 -3
  59. package/link/core/index.js.map +1 -1
  60. package/link/http/checkFetcher.js +2 -2
  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 +3 -3
  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 -0
  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 +2 -2
  75. package/link/http/serializeFetchParameter.js.map +1 -1
  76. package/link/persisted-queries/index.d.ts.map +1 -1
  77. package/link/persisted-queries/index.js +3 -3
  78. package/link/persisted-queries/index.js.map +1 -1
  79. package/link/persisted-queries/persisted-queries.cjs.js +5 -5
  80. package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
  81. package/link/utils/index.d.ts +1 -0
  82. package/link/utils/index.d.ts.map +1 -1
  83. package/link/utils/index.js +1 -0
  84. package/link/utils/index.js.map +1 -1
  85. package/link/utils/toPromise.d.ts.map +1 -1
  86. package/link/utils/toPromise.js +1 -1
  87. package/link/utils/toPromise.js.map +1 -1
  88. package/link/utils/utils.cjs.js +3 -3
  89. package/link/utils/utils.cjs.js.map +1 -1
  90. package/link/utils/validateOperation.d.ts.map +1 -1
  91. package/link/utils/validateOperation.js +2 -2
  92. package/link/utils/validateOperation.js.map +1 -1
  93. package/package.json +6 -6
  94. package/react/context/ApolloConsumer.d.ts.map +1 -1
  95. package/react/context/ApolloConsumer.js +2 -2
  96. package/react/context/ApolloConsumer.js.map +1 -1
  97. package/react/context/ApolloProvider.d.ts.map +1 -1
  98. package/react/context/ApolloProvider.js +2 -2
  99. package/react/context/ApolloProvider.js.map +1 -1
  100. package/react/context/context.cjs.js +5 -5
  101. package/react/context/context.cjs.js.map +1 -1
  102. package/react/context/index.d.ts +1 -0
  103. package/react/context/index.d.ts.map +1 -1
  104. package/react/context/index.js +1 -0
  105. package/react/context/index.js.map +1 -1
  106. package/react/data/OperationData.d.ts.map +1 -1
  107. package/react/data/OperationData.js +3 -3
  108. package/react/data/OperationData.js.map +1 -1
  109. package/react/data/QueryData.d.ts.map +1 -1
  110. package/react/data/QueryData.js +9 -11
  111. package/react/data/QueryData.js.map +1 -1
  112. package/react/data/data.cjs.js +14 -16
  113. package/react/data/data.cjs.js.map +1 -1
  114. package/react/data/index.d.ts +1 -0
  115. package/react/data/index.d.ts.map +1 -1
  116. package/react/data/index.js +1 -0
  117. package/react/data/index.js.map +1 -1
  118. package/react/hoc/hoc-utils.d.ts.map +1 -1
  119. package/react/hoc/hoc-utils.js +2 -2
  120. package/react/hoc/hoc-utils.js.map +1 -1
  121. package/react/hoc/hoc.cjs.js +5 -5
  122. package/react/hoc/hoc.cjs.js.map +1 -1
  123. package/react/hoc/index.d.ts +1 -0
  124. package/react/hoc/index.d.ts.map +1 -1
  125. package/react/hoc/index.js +1 -0
  126. package/react/hoc/index.js.map +1 -1
  127. package/react/hoc/withApollo.d.ts.map +1 -1
  128. package/react/hoc/withApollo.js +2 -2
  129. package/react/hoc/withApollo.js.map +1 -1
  130. package/react/hooks/hooks.cjs.js +3 -3
  131. package/react/hooks/hooks.cjs.js.map +1 -1
  132. package/react/hooks/index.d.ts +1 -0
  133. package/react/hooks/index.d.ts.map +1 -1
  134. package/react/hooks/index.js +1 -0
  135. package/react/hooks/index.js.map +1 -1
  136. package/react/hooks/useApolloClient.d.ts.map +1 -1
  137. package/react/hooks/useApolloClient.js +2 -2
  138. package/react/hooks/useApolloClient.js.map +1 -1
  139. package/react/hooks/useSubscription.d.ts +1 -0
  140. package/react/hooks/useSubscription.d.ts.map +1 -1
  141. package/react/hooks/useSubscription.js +1 -0
  142. package/react/hooks/useSubscription.js.map +1 -1
  143. package/react/hooks/utils/useAfterFastRefresh.d.ts +1 -0
  144. package/react/hooks/utils/useAfterFastRefresh.d.ts.map +1 -1
  145. package/react/hooks/utils/useAfterFastRefresh.js +1 -0
  146. package/react/hooks/utils/useAfterFastRefresh.js.map +1 -1
  147. package/react/hooks/utils/useBaseQuery.d.ts +1 -0
  148. package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
  149. package/react/hooks/utils/useBaseQuery.js +1 -0
  150. package/react/hooks/utils/useBaseQuery.js.map +1 -1
  151. package/react/index.d.ts +1 -0
  152. package/react/index.d.ts.map +1 -1
  153. package/react/index.js +1 -3
  154. package/react/index.js.map +1 -1
  155. package/react/parser/index.d.ts.map +1 -1
  156. package/react/parser/index.js +5 -5
  157. package/react/parser/index.js.map +1 -1
  158. package/react/parser/parser.cjs.js +10 -10
  159. package/react/parser/parser.cjs.js.map +1 -1
  160. package/react/react.cjs.js +2 -3
  161. package/react/react.cjs.js.map +1 -1
  162. package/testing/index.d.ts +1 -0
  163. package/testing/index.d.ts.map +1 -1
  164. package/testing/index.js +1 -3
  165. package/testing/index.js.map +1 -1
  166. package/testing/testing.cjs.js +3 -5
  167. package/testing/testing.cjs.js.map +1 -1
  168. package/utilities/globals/DEV.js +2 -2
  169. package/utilities/globals/DEV.js.map +1 -1
  170. package/utilities/{common → globals}/global.d.ts +0 -0
  171. package/utilities/globals/global.d.ts.map +1 -0
  172. package/utilities/{common → globals}/global.js +0 -0
  173. package/utilities/globals/global.js.map +1 -0
  174. package/utilities/globals/globals.cjs.js +56 -0
  175. package/utilities/globals/globals.cjs.js.map +1 -0
  176. package/utilities/globals/index.d.ts +5 -2
  177. package/utilities/globals/index.d.ts.map +1 -1
  178. package/utilities/globals/index.js +7 -1
  179. package/utilities/globals/index.js.map +1 -1
  180. package/utilities/{common → globals}/maybe.d.ts +0 -0
  181. package/utilities/globals/maybe.d.ts.map +1 -0
  182. package/utilities/{common → globals}/maybe.js +0 -0
  183. package/utilities/globals/maybe.js.map +1 -0
  184. package/utilities/globals/package.json +7 -0
  185. package/utilities/graphql/directives.d.ts.map +1 -1
  186. package/utilities/graphql/directives.js +5 -5
  187. package/utilities/graphql/directives.js.map +1 -1
  188. package/utilities/graphql/fragments.d.ts.map +1 -1
  189. package/utilities/graphql/fragments.js +4 -4
  190. package/utilities/graphql/fragments.js.map +1 -1
  191. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  192. package/utilities/graphql/getFromAST.js +9 -9
  193. package/utilities/graphql/getFromAST.js.map +1 -1
  194. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  195. package/utilities/graphql/storeUtils.js +2 -2
  196. package/utilities/graphql/storeUtils.js.map +1 -1
  197. package/utilities/graphql/transform.d.ts.map +1 -1
  198. package/utilities/graphql/transform.js +1 -1
  199. package/utilities/graphql/transform.js.map +1 -1
  200. package/utilities/index.d.ts +1 -3
  201. package/utilities/index.d.ts.map +1 -1
  202. package/utilities/index.js +1 -5
  203. package/utilities/index.js.map +1 -1
  204. package/utilities/observables/Concast.js +1 -1
  205. package/utilities/observables/Concast.js.map +1 -1
  206. package/utilities/package.json +1 -3
  207. package/utilities/testing/mocking/mockLink.d.ts.map +1 -1
  208. package/utilities/testing/mocking/mockLink.js +2 -2
  209. package/utilities/testing/mocking/mockLink.js.map +1 -1
  210. package/utilities/utilities.cjs.js +25 -66
  211. package/utilities/utilities.cjs.js.map +1 -1
  212. package/version.js +1 -1
  213. package/utilities/common/global.d.ts.map +0 -1
  214. package/utilities/common/global.js.map +0 -1
  215. package/utilities/common/maybe.d.ts.map +0 -1
  216. package/utilities/common/maybe.js.map +0 -1
@@ -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,37 +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
- removeTemporaryGlobals();
69
-
70
38
  function shouldInclude(_a, variables) {
71
39
  var directives = _a.directives;
72
40
  if (!directives || !directives.length) {
@@ -77,7 +45,7 @@ function shouldInclude(_a, variables) {
77
45
  var evaledValue = false;
78
46
  if (ifArgument.value.kind === 'Variable') {
79
47
  evaledValue = variables && variables[ifArgument.value.name.value];
80
- __DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 43);
48
+ __DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 39);
81
49
  }
82
50
  else {
83
51
  evaledValue = ifArgument.value.value;
@@ -114,13 +82,13 @@ function getInclusionDirectives(directives) {
114
82
  return;
115
83
  var directiveArguments = directive.arguments;
116
84
  var directiveName = directive.name.value;
117
- __DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 44);
85
+ __DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 40);
118
86
  var ifArgument = directiveArguments[0];
119
- __DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 45);
87
+ __DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 41);
120
88
  var ifValue = ifArgument.value;
121
89
  __DEV__ ? tsInvariant.invariant(ifValue &&
122
90
  (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.") : tsInvariant.invariant(ifValue &&
123
- (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 46);
91
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 42);
124
92
  result.push({ directive: directive, ifArgument: ifArgument });
125
93
  });
126
94
  }
@@ -133,14 +101,14 @@ function getFragmentQueryDocument(document, fragmentName) {
133
101
  document.definitions.forEach(function (definition) {
134
102
  if (definition.kind === 'OperationDefinition') {
135
103
  throw __DEV__ ? new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
136
- 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(47);
104
+ 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(43);
137
105
  }
138
106
  if (definition.kind === 'FragmentDefinition') {
139
107
  fragments.push(definition);
140
108
  }
141
109
  });
142
110
  if (typeof actualFragmentName === 'undefined') {
143
- __DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1, 48);
111
+ __DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : tsInvariant.invariant(fragments.length === 1, 44);
144
112
  actualFragmentName = fragments[0].name.value;
145
113
  }
146
114
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -177,7 +145,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
177
145
  return selection;
178
146
  case 'FragmentSpread': {
179
147
  var fragment = fragmentMap && fragmentMap[selection.name.value];
180
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 49);
148
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 45);
181
149
  return fragment;
182
150
  }
183
151
  default:
@@ -261,7 +229,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
261
229
  else {
262
230
  throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
263
231
  'is not supported. Use variables instead of inline arguments to ' +
264
- 'overcome this limitation.') : new tsInvariant.InvariantError(58);
232
+ 'overcome this limitation.') : new tsInvariant.InvariantError(54);
265
233
  }
266
234
  }
267
235
  function storeKeyNameFromField(field, variables) {
@@ -395,16 +363,16 @@ function isInlineFragment(selection) {
395
363
  }
396
364
 
397
365
  function checkDocument(doc) {
398
- __DEV__ ? tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc && doc.kind === 'Document', 50);
366
+ __DEV__ ? tsInvariant.invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc && doc.kind === 'Document', 46);
399
367
  var operations = doc.definitions
400
368
  .filter(function (d) { return d.kind !== 'FragmentDefinition'; })
401
369
  .map(function (definition) {
402
370
  if (definition.kind !== 'OperationDefinition') {
403
- throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(51);
371
+ throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(47);
404
372
  }
405
373
  return definition;
406
374
  });
407
- __DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 52);
375
+ __DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 48);
408
376
  return doc;
409
377
  }
410
378
  function getOperationDefinition(doc) {
@@ -423,14 +391,14 @@ function getFragmentDefinitions(doc) {
423
391
  }
424
392
  function getQueryDefinition(doc) {
425
393
  var queryDef = getOperationDefinition(doc);
426
- __DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 53);
394
+ __DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 49);
427
395
  return queryDef;
428
396
  }
429
397
  function getFragmentDefinition(doc) {
430
- __DEV__ ? tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc.kind === 'Document', 54);
431
- __DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 55);
398
+ __DEV__ ? tsInvariant.invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql") : tsInvariant.invariant(doc.kind === 'Document', 50);
399
+ __DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 51);
432
400
  var fragmentDef = doc.definitions[0];
433
- __DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 56);
401
+ __DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 52);
434
402
  return fragmentDef;
435
403
  }
436
404
  function getMainDefinition(queryDoc) {
@@ -453,7 +421,7 @@ function getMainDefinition(queryDoc) {
453
421
  if (fragmentDefinition) {
454
422
  return fragmentDefinition;
455
423
  }
456
- throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(57);
424
+ throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(53);
457
425
  }
458
426
  function getDefaultValues(definition) {
459
427
  var defaultValues = Object.create(null);
@@ -735,7 +703,7 @@ function removeClientSetsFromDocument(document) {
735
703
  return modifiedDoc;
736
704
  }
737
705
 
738
- var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
706
+ var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
739
707
  function mergeDeep() {
740
708
  var sources = [];
741
709
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -772,7 +740,7 @@ var DeepMerger = (function () {
772
740
  }
773
741
  if (isNonNullObject(source) && isNonNullObject(target)) {
774
742
  Object.keys(source).forEach(function (sourceKey) {
775
- if (hasOwnProperty$2.call(target, sourceKey)) {
743
+ if (hasOwnProperty$3.call(target, sourceKey)) {
776
744
  var targetValue = target[sourceKey];
777
745
  if (source[sourceKey] !== targetValue) {
778
746
  var result = _this.reconciler.apply(_this, tslib.__spreadArray([target, source, sourceKey], context));
@@ -952,7 +920,7 @@ var Concast = (function (_super) {
952
920
  var sub = _this.sub;
953
921
  if (sub !== null) {
954
922
  if (sub)
955
- Promise.resolve().then(function () { return sub.unsubscribe(); });
923
+ setTimeout(function () { return sub.unsubscribe(); });
956
924
  _this.sub = null;
957
925
  _this.latest = ["error", error];
958
926
  _this.reject(error);
@@ -1101,8 +1069,6 @@ function stringifyForDisplay(value) {
1101
1069
  }).split(JSON.stringify(undefId)).join("<undefined>");
1102
1070
  }
1103
1071
 
1104
- __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 59);
1105
-
1106
1072
  function fromError(errorValue) {
1107
1073
  return new zenObservableTs.Observable(function (observer) {
1108
1074
  observer.error(errorValue);
@@ -1158,7 +1124,7 @@ function validateOperation(operation) {
1158
1124
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
1159
1125
  var key = _a[_i];
1160
1126
  if (OPERATION_FIELDS.indexOf(key) < 0) {
1161
- throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(29);
1127
+ throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(26);
1162
1128
  }
1163
1129
  }
1164
1130
  return operation;
@@ -1281,7 +1247,7 @@ var ApolloLink = (function () {
1281
1247
  return ApolloLink.concat(this, next);
1282
1248
  };
1283
1249
  ApolloLink.prototype.request = function (operation, forward) {
1284
- throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(23);
1250
+ throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(21);
1285
1251
  };
1286
1252
  ApolloLink.prototype.onError = function (error, observer) {
1287
1253
  if (observer && observer.error) {
@@ -1307,9 +1273,9 @@ var concat = ApolloLink.concat;
1307
1273
 
1308
1274
  var execute = ApolloLink.execute;
1309
1275
 
1310
- var version = '3.4.6';
1276
+ var version = '3.4.10';
1311
1277
 
1312
- var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1278
+ var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1313
1279
  function parseAndCheckHttpResponse(operations) {
1314
1280
  return function (response) { return response
1315
1281
  .text()
@@ -1331,8 +1297,8 @@ function parseAndCheckHttpResponse(operations) {
1331
1297
  throwServerError(response, result, "Response not successful: Received status code " + response.status);
1332
1298
  }
1333
1299
  if (!Array.isArray(result) &&
1334
- !hasOwnProperty$1.call(result, 'data') &&
1335
- !hasOwnProperty$1.call(result, 'errors')) {
1300
+ !hasOwnProperty$2.call(result, 'data') &&
1301
+ !hasOwnProperty$2.call(result, 'errors')) {
1336
1302
  throwServerError(response, result, "Server response was missing for query '" + (Array.isArray(operations)
1337
1303
  ? operations.map(function (op) { return op.operationName; })
1338
1304
  : operations.operationName) + "'.");
@@ -1347,7 +1313,7 @@ var serializeFetchParameter = function (p, label) {
1347
1313
  serialized = JSON.stringify(p);
1348
1314
  }
1349
1315
  catch (e) {
1350
- var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(26);
1316
+ var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(23);
1351
1317
  parseError.parseError = e;
1352
1318
  throw parseError;
1353
1319
  }
@@ -1407,7 +1373,7 @@ function headersToLowerCase(headers) {
1407
1373
 
1408
1374
  var checkFetcher = function (fetcher) {
1409
1375
  if (!fetcher && typeof fetch === 'undefined') {
1410
- throw __DEV__ ? new tsInvariant.InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ") : new tsInvariant.InvariantError(25);
1376
+ throw __DEV__ ? new tsInvariant.InvariantError("\n\"fetch\" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:\n\nimport fetch from 'cross-fetch';\nimport { ApolloClient, HttpLink } from '@apollo/client';\nconst client = new ApolloClient({\n link: new HttpLink({ uri: '/graphql', fetch })\n});\n ") : new tsInvariant.InvariantError(22);
1411
1377
  }
1412
1378
  };
1413
1379
 
@@ -1787,7 +1753,7 @@ var EntityStore = (function () {
1787
1753
  : newer;
1788
1754
  if (!incoming)
1789
1755
  return;
1790
- __DEV__ ? tsInvariant.invariant(typeof dataId === "string", "store.merge expects a string ID") : tsInvariant.invariant(typeof dataId === "string", 2);
1756
+ __DEV__ ? tsInvariant.invariant(typeof dataId === "string", "store.merge expects a string ID") : tsInvariant.invariant(typeof dataId === "string", 1);
1791
1757
  var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
1792
1758
  this.data[dataId] = merged;
1793
1759
  if (merged !== existing) {
@@ -2378,7 +2344,7 @@ var StoreReader = (function () {
2378
2344
  !context.store.has(objectOrReference.__ref)) {
2379
2345
  return {
2380
2346
  result: this.canon.empty,
2381
- missing: [missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object") : new tsInvariant.InvariantError(6), context)],
2347
+ missing: [missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object") : new tsInvariant.InvariantError(5), context)],
2382
2348
  };
2383
2349
  }
2384
2350
  var variables = context.variables, policies = context.policies, store = context.store;
@@ -2417,7 +2383,7 @@ var StoreReader = (function () {
2417
2383
  if (!addTypenameToDocument.added(selection)) {
2418
2384
  getMissing().push(missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Can't find field '" + selection.name.value + "' on " + (isReference(objectOrReference)
2419
2385
  ? objectOrReference.__ref + " object"
2420
- : "object " + JSON.stringify(objectOrReference, null, 2))) : new tsInvariant.InvariantError(7), context));
2386
+ : "object " + JSON.stringify(objectOrReference, null, 2))) : new tsInvariant.InvariantError(6), context));
2421
2387
  }
2422
2388
  }
2423
2389
  else if (Array.isArray(fieldValue)) {
@@ -2514,7 +2480,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
2514
2480
  var workSet_1 = new Set([fieldValue]);
2515
2481
  workSet_1.forEach(function (value) {
2516
2482
  if (isNonNullObject(value)) {
2517
- __DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value) : tsInvariant.invariant(!isReference(value), 8);
2483
+ __DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value) : tsInvariant.invariant(!isReference(value), 7);
2518
2484
  Object.values(value).forEach(workSet_1.add, workSet_1);
2519
2485
  }
2520
2486
  });
@@ -2553,12 +2519,12 @@ var StoreWriter = (function () {
2553
2519
  context: context,
2554
2520
  });
2555
2521
  if (!isReference(ref)) {
2556
- throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(9);
2522
+ throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(8);
2557
2523
  }
2558
2524
  context.incomingById.forEach(function (_a, dataId) {
2559
2525
  var fields = _a.fields, mergeTree = _a.mergeTree, selections = _a.selections;
2560
2526
  var entityRef = makeReference(dataId);
2561
- if (mergeTree.map.size) {
2527
+ if (mergeTree && mergeTree.map.size) {
2562
2528
  var applied = _this.applyMerges(mergeTree, entityRef, fields, context);
2563
2529
  if (isReference(applied)) {
2564
2530
  return;
@@ -2576,7 +2542,7 @@ var StoreWriter = (function () {
2576
2542
  }
2577
2543
  });
2578
2544
  var hasMergeFunction_1 = function (storeFieldName) {
2579
- var childTree = mergeTree.map.get(storeFieldName);
2545
+ var childTree = mergeTree && mergeTree.map.get(storeFieldName);
2580
2546
  return Boolean(childTree && childTree.info && childTree.info.merge);
2581
2547
  };
2582
2548
  Object.keys(fields).forEach(function (storeFieldName) {
@@ -2685,7 +2651,7 @@ var StoreWriter = (function () {
2685
2651
  else {
2686
2652
  context.incomingById.set(dataId, {
2687
2653
  fields: incomingFields,
2688
- mergeTree: mergeTree,
2654
+ mergeTree: mergeTreeIsEmpty(mergeTree) ? void 0 : mergeTree,
2689
2655
  selections: selections,
2690
2656
  });
2691
2657
  }
@@ -3050,7 +3016,7 @@ var Policies = (function () {
3050
3016
  var rootId = "ROOT_" + which.toUpperCase();
3051
3017
  var old = this.rootTypenamesById[rootId];
3052
3018
  if (typename !== old) {
3053
- __DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which, 3);
3019
+ __DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which, 2);
3054
3020
  if (old)
3055
3021
  delete this.rootIdsByTypename[old];
3056
3022
  this.rootIdsByTypename[typename] = rootId;
@@ -3294,7 +3260,7 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
3294
3260
  function makeMergeObjectsFunction(store) {
3295
3261
  return function mergeObjects(existing, incoming) {
3296
3262
  if (Array.isArray(existing) || Array.isArray(incoming)) {
3297
- throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(4);
3263
+ throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(3);
3298
3264
  }
3299
3265
  if (isNonNullObject(existing) &&
3300
3266
  isNonNullObject(incoming)) {
@@ -3375,24 +3341,27 @@ function makeAliasMap(selectionSet, fragmentMap) {
3375
3341
  }
3376
3342
  function computeKeyObject(response, specifier, strict, aliasMap) {
3377
3343
  var keyObj = Object.create(null);
3378
- var prevKey;
3344
+ var lastResponseKey;
3345
+ var lastActualKey;
3379
3346
  specifier.forEach(function (s) {
3380
3347
  if (Array.isArray(s)) {
3381
- if (typeof prevKey === "string") {
3348
+ if (typeof lastActualKey === "string" &&
3349
+ typeof lastResponseKey === "string") {
3382
3350
  var subsets = aliasMap && aliasMap.subsets;
3383
- var subset = subsets && subsets[prevKey];
3384
- keyObj[prevKey] = computeKeyObject(response[prevKey], s, strict, subset);
3351
+ var subset = subsets && subsets[lastActualKey];
3352
+ keyObj[lastActualKey] =
3353
+ computeKeyObject(response[lastResponseKey], s, strict, subset);
3385
3354
  }
3386
3355
  }
3387
3356
  else {
3388
3357
  var aliases = aliasMap && aliasMap.aliases;
3389
3358
  var responseName = aliases && aliases[s] || s;
3390
3359
  if (hasOwn.call(response, responseName)) {
3391
- keyObj[prevKey = s] = response[responseName];
3360
+ keyObj[lastActualKey = s] = response[lastResponseKey = responseName];
3392
3361
  }
3393
3362
  else {
3394
- __DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict, 5);
3395
- prevKey = void 0;
3363
+ __DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict, 4);
3364
+ lastResponseKey = lastActualKey = void 0;
3396
3365
  }
3397
3366
  }
3398
3367
  });
@@ -3684,7 +3653,6 @@ var InMemoryCache = (function (_super) {
3684
3653
  return InMemoryCache;
3685
3654
  }(ApolloCache));
3686
3655
 
3687
- __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 22);
3688
3656
  function isApolloError(err) {
3689
3657
  return err.hasOwnProperty('graphQLErrors');
3690
3658
  }
@@ -3736,6 +3704,7 @@ function isNetworkRequestInFlight(networkStatus) {
3736
3704
  return networkStatus ? networkStatus < 7 : false;
3737
3705
  }
3738
3706
 
3707
+ var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
3739
3708
  var warnedAboutUpdateQuery = false;
3740
3709
  var ObservableQuery = (function (_super) {
3741
3710
  tslib.__extends(ObservableQuery, _super);
@@ -3751,11 +3720,12 @@ var ObservableQuery = (function (_super) {
3751
3720
  catch (_a) { }
3752
3721
  var first = !_this.observers.size;
3753
3722
  _this.observers.add(observer);
3754
- if (_this.lastError) {
3755
- observer.error && observer.error(_this.lastError);
3723
+ var last = _this.last;
3724
+ if (last && last.error) {
3725
+ observer.error && observer.error(last.error);
3756
3726
  }
3757
- else if (_this.lastResult) {
3758
- observer.next && observer.next(_this.lastResult);
3727
+ else if (last && last.result) {
3728
+ observer.next && observer.next(last.result);
3759
3729
  }
3760
3730
  if (first) {
3761
3731
  _this.reobserve().catch(function () { });
@@ -3768,18 +3738,6 @@ var ObservableQuery = (function (_super) {
3768
3738
  }) || this;
3769
3739
  _this.observers = new Set();
3770
3740
  _this.subscriptions = new Set();
3771
- _this.observer = {
3772
- next: function (result) {
3773
- if (_this.lastError || _this.isDifferentFromLastResult(result)) {
3774
- _this.updateLastResult(result);
3775
- iterateObserversSafely(_this.observers, 'next', result);
3776
- }
3777
- },
3778
- error: function (error) {
3779
- _this.updateLastResult(tslib.__assign(tslib.__assign({}, _this.lastResult), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false }));
3780
- iterateObserversSafely(_this.observers, 'error', _this.lastError = error);
3781
- },
3782
- };
3783
3741
  _this.isTornDown = false;
3784
3742
  _this.options = options;
3785
3743
  _this.queryId = queryInfo.queryId || queryManager.generateQueryId();
@@ -3818,15 +3776,24 @@ var ObservableQuery = (function (_super) {
3818
3776
  };
3819
3777
  ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
3820
3778
  if (saveAsLastResult === void 0) { saveAsLastResult = true; }
3821
- var _a = this, lastResult = _a.lastResult, _b = _a.options.fetchPolicy, fetchPolicy = _b === void 0 ? "cache-first" : _b;
3779
+ var lastResult = this.getLastResult(true);
3822
3780
  var networkStatus = this.queryInfo.networkStatus ||
3823
3781
  (lastResult && lastResult.networkStatus) ||
3824
3782
  exports.NetworkStatus.ready;
3825
3783
  var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
3826
- if (!this.queryManager.transform(this.options.query).hasForcedResolvers) {
3784
+ var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
3785
+ var shouldReturnCachedData = lastResult || (fetchPolicy !== 'network-only' &&
3786
+ fetchPolicy !== 'no-cache' &&
3787
+ fetchPolicy !== 'standby');
3788
+ if (shouldReturnCachedData &&
3789
+ !this.queryManager.transform(this.options.query).hasForcedResolvers) {
3827
3790
  var diff = this.queryInfo.getDiff();
3828
- result.data = (diff.complete ||
3829
- this.options.returnPartialData) ? diff.result : void 0;
3791
+ if (diff.complete || this.options.returnPartialData) {
3792
+ result.data = diff.result;
3793
+ }
3794
+ if (equality.equal(result.data, {})) {
3795
+ result.data = void 0;
3796
+ }
3830
3797
  if (diff.complete) {
3831
3798
  if (result.networkStatus === exports.NetworkStatus.loading &&
3832
3799
  (fetchPolicy === 'cache-first' ||
@@ -3854,24 +3821,31 @@ var ObservableQuery = (function (_super) {
3854
3821
  return result;
3855
3822
  };
3856
3823
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult) {
3857
- return !equality.equal(this.lastResultSnapshot, newResult);
3824
+ return !this.last || !equality.equal(this.last.result, newResult);
3858
3825
  };
3859
- ObservableQuery.prototype.getLastResult = function () {
3860
- return this.lastResult;
3826
+ ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
3827
+ var last = this.last;
3828
+ if (last &&
3829
+ last[key] &&
3830
+ (!variablesMustMatch || equality.equal(last.variables, this.variables))) {
3831
+ return last[key];
3832
+ }
3833
+ };
3834
+ ObservableQuery.prototype.getLastResult = function (variablesMustMatch) {
3835
+ return this.getLast("result", variablesMustMatch);
3861
3836
  };
3862
- ObservableQuery.prototype.getLastError = function () {
3863
- return this.lastError;
3837
+ ObservableQuery.prototype.getLastError = function (variablesMustMatch) {
3838
+ return this.getLast("error", variablesMustMatch);
3864
3839
  };
3865
3840
  ObservableQuery.prototype.resetLastResults = function () {
3866
- delete this.lastResult;
3867
- delete this.lastResultSnapshot;
3868
- delete this.lastError;
3841
+ delete this.last;
3869
3842
  this.isTornDown = false;
3870
3843
  };
3871
3844
  ObservableQuery.prototype.resetQueryStoreErrors = function () {
3872
3845
  this.queryManager.resetErrors(this.queryId);
3873
3846
  };
3874
3847
  ObservableQuery.prototype.refetch = function (variables) {
3848
+ var _a;
3875
3849
  var reobserveOptions = {
3876
3850
  pollInterval: 0,
3877
3851
  };
@@ -3882,6 +3856,13 @@ var ObservableQuery = (function (_super) {
3882
3856
  else if (fetchPolicy !== 'cache-and-network') {
3883
3857
  reobserveOptions.fetchPolicy = 'network-only';
3884
3858
  }
3859
+ if (__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
3860
+ var queryDef = getQueryDefinition(this.options.query);
3861
+ var vars = queryDef.variableDefinitions;
3862
+ if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
3863
+ __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 })?");
3864
+ }
3865
+ }
3885
3866
  if (variables && !equality.equal(this.options.variables, variables)) {
3886
3867
  reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
3887
3868
  }
@@ -3978,12 +3959,10 @@ var ObservableQuery = (function (_super) {
3978
3959
  }, exports.NetworkStatus.setVariables);
3979
3960
  };
3980
3961
  ObservableQuery.prototype.updateQuery = function (mapFn) {
3981
- var _a;
3982
3962
  var queryManager = this.queryManager;
3983
3963
  var result = queryManager.cache.diff({
3984
3964
  query: this.options.query,
3985
3965
  variables: this.variables,
3986
- previousResult: (_a = this.lastResult) === null || _a === void 0 ? void 0 : _a.data,
3987
3966
  returnPartialData: true,
3988
3967
  optimistic: false,
3989
3968
  }).result;
@@ -4028,7 +4007,7 @@ var ObservableQuery = (function (_super) {
4028
4007
  pollingInfo.interval === pollInterval) {
4029
4008
  return;
4030
4009
  }
4031
- __DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 13);
4010
+ __DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 12);
4032
4011
  var info = pollingInfo || (this.pollingInfo = {});
4033
4012
  info.interval = pollInterval;
4034
4013
  var maybeFetch = function () {
@@ -4052,18 +4031,18 @@ var ObservableQuery = (function (_super) {
4052
4031
  };
4053
4032
  poll();
4054
4033
  };
4055
- ObservableQuery.prototype.updateLastResult = function (newResult) {
4056
- var previousResult = this.lastResult;
4057
- this.lastResult = newResult;
4058
- this.lastResultSnapshot = this.queryManager.assumeImmutableResults
4059
- ? newResult
4060
- : cloneDeep(newResult);
4034
+ ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
4035
+ if (variables === void 0) { variables = this.variables; }
4036
+ this.last = tslib.__assign(tslib.__assign({}, this.last), { result: this.queryManager.assumeImmutableResults
4037
+ ? newResult
4038
+ : cloneDeep(newResult), variables: variables });
4061
4039
  if (!isNonEmptyArray(newResult.errors)) {
4062
- delete this.lastError;
4040
+ delete this.last.error;
4063
4041
  }
4064
- return previousResult;
4042
+ return this.last;
4065
4043
  };
4066
4044
  ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
4045
+ var _this = this;
4067
4046
  this.isTornDown = false;
4068
4047
  var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
4069
4048
  newNetworkStatus === exports.NetworkStatus.fetchMore ||
@@ -4071,7 +4050,7 @@ var ObservableQuery = (function (_super) {
4071
4050
  var oldVariables = this.options.variables;
4072
4051
  var options = useDisposableConcast
4073
4052
  ? compact(this.options, newOptions)
4074
- : Object.assign(this.options, compact(newOptions));
4053
+ : assign(this.options, compact(newOptions));
4075
4054
  if (!useDisposableConcast) {
4076
4055
  this.updatePolling();
4077
4056
  if (newOptions &&
@@ -4084,18 +4063,39 @@ var ObservableQuery = (function (_super) {
4084
4063
  }
4085
4064
  }
4086
4065
  }
4066
+ var variables = options.variables && tslib.__assign({}, options.variables);
4087
4067
  var concast = this.fetch(options, newNetworkStatus);
4068
+ var observer = {
4069
+ next: function (result) {
4070
+ _this.reportResult(result, variables);
4071
+ },
4072
+ error: function (error) {
4073
+ _this.reportError(error, variables);
4074
+ },
4075
+ };
4088
4076
  if (!useDisposableConcast) {
4089
- if (this.concast) {
4077
+ if (this.concast && this.observer) {
4090
4078
  this.concast.removeObserver(this.observer, true);
4091
4079
  }
4092
4080
  this.concast = concast;
4081
+ this.observer = observer;
4093
4082
  }
4094
- concast.addObserver(this.observer);
4083
+ concast.addObserver(observer);
4095
4084
  return concast.promise;
4096
4085
  };
4097
4086
  ObservableQuery.prototype.observe = function () {
4098
- this.observer.next(this.getCurrentResult(false));
4087
+ this.reportResult(this.getCurrentResult(false), this.variables);
4088
+ };
4089
+ ObservableQuery.prototype.reportResult = function (result, variables) {
4090
+ if (this.getLastError() || this.isDifferentFromLastResult(result)) {
4091
+ this.updateLastResult(result, variables);
4092
+ iterateObserversSafely(this.observers, 'next', result);
4093
+ }
4094
+ };
4095
+ ObservableQuery.prototype.reportError = function (error, variables) {
4096
+ var errorResult = tslib.__assign(tslib.__assign({}, this.getLastResult()), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false });
4097
+ this.updateLastResult(errorResult, variables);
4098
+ iterateObserversSafely(this.observers, 'error', this.last.error = error);
4099
4099
  };
4100
4100
  ObservableQuery.prototype.hasObservers = function () {
4101
4101
  return this.observers.size > 0;
@@ -4103,9 +4103,10 @@ var ObservableQuery = (function (_super) {
4103
4103
  ObservableQuery.prototype.tearDownQuery = function () {
4104
4104
  if (this.isTornDown)
4105
4105
  return;
4106
- if (this.concast) {
4106
+ if (this.concast && this.observer) {
4107
4107
  this.concast.removeObserver(this.observer);
4108
4108
  delete this.concast;
4109
+ delete this.observer;
4109
4110
  }
4110
4111
  this.stopPolling();
4111
4112
  this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
@@ -4303,7 +4304,7 @@ var LocalState = (function () {
4303
4304
  }
4304
4305
  else {
4305
4306
  fragment = fragmentMap[selection.name.value];
4306
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 12);
4307
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 11);
4307
4308
  }
4308
4309
  if (fragment && fragment.typeCondition) {
4309
4310
  typeCondition = fragment.typeCondition.name.value;
@@ -4689,7 +4690,7 @@ var QueryManager = (function () {
4689
4690
  this.queries.forEach(function (_info, queryId) {
4690
4691
  _this.stopQueryNoBroadcast(queryId);
4691
4692
  });
4692
- this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(14));
4693
+ this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(13));
4693
4694
  };
4694
4695
  QueryManager.prototype.cancelPendingFetches = function (error) {
4695
4696
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -4702,10 +4703,10 @@ var QueryManager = (function () {
4702
4703
  return tslib.__generator(this, function (_f) {
4703
4704
  switch (_f.label) {
4704
4705
  case 0:
4705
- __DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 15);
4706
+ __DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 14);
4706
4707
  __DEV__ ? tsInvariant.invariant(fetchPolicy === 'network-only' ||
4707
4708
  fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.") : tsInvariant.invariant(fetchPolicy === 'network-only' ||
4708
- fetchPolicy === 'no-cache', 16);
4709
+ fetchPolicy === 'no-cache', 15);
4709
4710
  mutationId = this.generateMutationId();
4710
4711
  mutation = this.transform(mutation).document;
4711
4712
  variables = this.getVariables(mutation, variables);
@@ -4990,10 +4991,10 @@ var QueryManager = (function () {
4990
4991
  var _this = this;
4991
4992
  if (queryId === void 0) { queryId = this.generateQueryId(); }
4992
4993
  __DEV__ ? tsInvariant.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
4993
- 'in the query option.') : tsInvariant.invariant(options.query, 17);
4994
- __DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 18);
4995
- __DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 19);
4996
- __DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 20);
4994
+ 'in the query option.') : tsInvariant.invariant(options.query, 16);
4995
+ __DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 17);
4996
+ __DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 18);
4997
+ __DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 19);
4997
4998
  return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
4998
4999
  };
4999
5000
  QueryManager.prototype.generateQueryId = function () {
@@ -5015,7 +5016,7 @@ var QueryManager = (function () {
5015
5016
  queryInfo.stop();
5016
5017
  };
5017
5018
  QueryManager.prototype.clearStore = function () {
5018
- this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(21));
5019
+ this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(20));
5019
5020
  this.queries.forEach(function (queryInfo) {
5020
5021
  if (queryInfo.observableQuery) {
5021
5022
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -5290,7 +5291,7 @@ var QueryManager = (function () {
5290
5291
  return _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
5291
5292
  };
5292
5293
  this.fetchCancelFns.set(queryId, function (reason) {
5293
- Promise.resolve().then(function () { return concast.cancel(reason); });
5294
+ setTimeout(function () { return concast.cancel(reason); });
5294
5295
  });
5295
5296
  var concast = new Concast(this.transform(normalized.query).hasClientExports
5296
5297
  ? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
@@ -5508,7 +5509,7 @@ var ApolloClient = (function () {
5508
5509
  if (!cache) {
5509
5510
  throw __DEV__ ? new tsInvariant.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
5510
5511
  "in the options object. \n" +
5511
- "For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(10);
5512
+ "For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(9);
5512
5513
  }
5513
5514
  this.link = link;
5514
5515
  this.cache = cache;
@@ -5604,7 +5605,7 @@ var ApolloClient = (function () {
5604
5605
  __DEV__ ? tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
5605
5606
  'client.query can only return a single result. Please use client.watchQuery ' +
5606
5607
  'to receive multiple results from the cache and the network, or consider ' +
5607
- 'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 11);
5608
+ 'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 10);
5608
5609
  if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
5609
5610
  options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
5610
5611
  }
@@ -5730,7 +5731,7 @@ var ApolloConsumer = function (props) {
5730
5731
  var ApolloContext = getApolloContext();
5731
5732
  return React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
5732
5733
  __DEV__ ? tsInvariant.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
5733
- 'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client, 30);
5734
+ 'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client, 27);
5734
5735
  return props.children(context.client);
5735
5736
  });
5736
5737
  };
@@ -5744,7 +5745,7 @@ var ApolloProvider = function (_a) {
5744
5745
  context = Object.assign({}, context, { client: client });
5745
5746
  }
5746
5747
  __DEV__ ? tsInvariant.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
5747
- 'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client, 31);
5748
+ 'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client, 28);
5748
5749
  return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
5749
5750
  });
5750
5751
  };
@@ -5752,7 +5753,7 @@ var ApolloProvider = function (_a) {
5752
5753
  function useApolloClient() {
5753
5754
  var client = React__namespace.useContext(getApolloContext()).client;
5754
5755
  __DEV__ ? tsInvariant.invariant(client, 'No Apollo Client instance can be found. Please ensure that you ' +
5755
- 'have called `ApolloProvider` higher up in your tree.') : tsInvariant.invariant(client, 36);
5756
+ 'have called `ApolloProvider` higher up in your tree.') : tsInvariant.invariant(client, 33);
5756
5757
  return client;
5757
5758
  }
5758
5759
 
@@ -5785,7 +5786,7 @@ function parser(document) {
5785
5786
  var variables, type, name;
5786
5787
  __DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of " + document + " passed to parser was not a valid GraphQL " +
5787
5788
  "DocumentNode. You may need to use 'graphql-tag' or another method " +
5788
- "to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 38);
5789
+ "to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 34);
5789
5790
  var fragments = document.definitions.filter(function (x) { return x.kind === 'FragmentDefinition'; });
5790
5791
  var queries = document.definitions.filter(function (x) {
5791
5792
  return x.kind === 'OperationDefinition' && x.operation === 'query';
@@ -5799,11 +5800,11 @@ function parser(document) {
5799
5800
  __DEV__ ? tsInvariant.invariant(!fragments.length ||
5800
5801
  (queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
5801
5802
  "You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
5802
- (queries.length || mutations.length || subscriptions.length), 39);
5803
+ (queries.length || mutations.length || subscriptions.length), 35);
5803
5804
  __DEV__ ? tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
5804
5805
  (document + " had " + queries.length + " queries, " + subscriptions.length + " ") +
5805
5806
  ("subscriptions and " + mutations.length + " mutations. ") +
5806
- "You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, 40);
5807
+ "You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, 36);
5807
5808
  type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
5808
5809
  if (!queries.length && !mutations.length)
5809
5810
  type = exports.DocumentType.Subscription;
@@ -5814,7 +5815,7 @@ function parser(document) {
5814
5815
  : subscriptions;
5815
5816
  __DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. " + document + " had " +
5816
5817
  (definitions.length + " definitions. ") +
5817
- "You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 41);
5818
+ "You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 37);
5818
5819
  var definition = definitions[0];
5819
5820
  variables = definition.variableDefinitions || [];
5820
5821
  if (definition.name && definition.name.kind === 'Name') {
@@ -5855,7 +5856,7 @@ var OperationData = (function () {
5855
5856
  (this.context && this.context.client);
5856
5857
  __DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
5857
5858
  'Wrap the root component in an <ApolloProvider>, or pass an ' +
5858
- 'ApolloClient instance in via options.') : tsInvariant.invariant(!!client, 32);
5859
+ 'ApolloClient instance in via options.') : tsInvariant.invariant(!!client, 29);
5859
5860
  var isNew = false;
5860
5861
  if (client !== this.client) {
5861
5862
  isNew = true;
@@ -5872,7 +5873,7 @@ var OperationData = (function () {
5872
5873
  var requiredOperationName = operationName(type);
5873
5874
  var usedOperationName = operationName(operation.type);
5874
5875
  __DEV__ ? tsInvariant.invariant(operation.type === type, "Running a " + requiredOperationName + " requires a graphql " +
5875
- (requiredOperationName + ", but a " + usedOperationName + " was used instead.")) : tsInvariant.invariant(operation.type === type, 33);
5876
+ (requiredOperationName + ", but a " + usedOperationName + " was used instead.")) : tsInvariant.invariant(operation.type === type, 30);
5876
5877
  };
5877
5878
  return OperationData;
5878
5879
  }());
@@ -6166,9 +6167,7 @@ var QueryData = (function (_super) {
6166
6167
  var _b = _a === void 0 ? {} : _a, _c = _b.lazy, lazy = _c === void 0 ? false : _c;
6167
6168
  this.isMounted = true;
6168
6169
  var options = this.getOptions();
6169
- if (this.currentObservable &&
6170
- !this.ssrInitiated() &&
6171
- !this.client.disableNetworkFetches) {
6170
+ if (this.currentObservable && !this.ssrInitiated()) {
6172
6171
  this.startQuerySubscription();
6173
6172
  }
6174
6173
  if (!lazy || this.runLazy) {
@@ -6288,14 +6287,14 @@ var QueryData = (function (_super) {
6288
6287
  this.removeQuerySubscription();
6289
6288
  var currentObservable = this.currentObservable;
6290
6289
  if (currentObservable) {
6291
- var lastError = currentObservable.getLastError();
6292
- var lastResult = currentObservable.getLastResult();
6293
- currentObservable.resetLastResults();
6294
- this.startQuerySubscription();
6295
- Object.assign(currentObservable, {
6296
- lastError: lastError,
6297
- lastResult: lastResult
6298
- });
6290
+ var last = currentObservable["last"];
6291
+ try {
6292
+ currentObservable.resetLastResults();
6293
+ this.startQuerySubscription();
6294
+ }
6295
+ finally {
6296
+ currentObservable["last"] = last;
6297
+ }
6299
6298
  }
6300
6299
  };
6301
6300
  QueryData.prototype.getExecuteResult = function () {