@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
@@ -62,7 +62,7 @@ function shouldInclude(_a, variables) {
62
62
  var evaledValue = false;
63
63
  if (ifArgument.value.kind === 'Variable') {
64
64
  evaledValue = variables && variables[ifArgument.value.name.value];
65
- __DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 43);
65
+ __DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 39);
66
66
  }
67
67
  else {
68
68
  evaledValue = ifArgument.value.value;
@@ -99,13 +99,13 @@ function getInclusionDirectives(directives) {
99
99
  return;
100
100
  var directiveArguments = directive.arguments;
101
101
  var directiveName = directive.name.value;
102
- __DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 44);
102
+ __DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 40);
103
103
  var ifArgument = directiveArguments[0];
104
- __DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 45);
104
+ __DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 41);
105
105
  var ifValue = ifArgument.value;
106
106
  __DEV__ ? tsInvariant.invariant(ifValue &&
107
107
  (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.") : tsInvariant.invariant(ifValue &&
108
- (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 46);
108
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 42);
109
109
  result.push({ directive: directive, ifArgument: ifArgument });
110
110
  });
111
111
  }
@@ -118,14 +118,14 @@ function getFragmentQueryDocument(document, fragmentName) {
118
118
  document.definitions.forEach(function (definition) {
119
119
  if (definition.kind === 'OperationDefinition') {
120
120
  throw __DEV__ ? new tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
121
- 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(47);
121
+ 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(43);
122
122
  }
123
123
  if (definition.kind === 'FragmentDefinition') {
124
124
  fragments.push(definition);
125
125
  }
126
126
  });
127
127
  if (typeof actualFragmentName === 'undefined') {
128
- __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);
128
+ __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);
129
129
  actualFragmentName = fragments[0].name.value;
130
130
  }
131
131
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -162,7 +162,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
162
162
  return selection;
163
163
  case 'FragmentSpread': {
164
164
  var fragment = fragmentMap && fragmentMap[selection.name.value];
165
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 49);
165
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 45);
166
166
  return fragment;
167
167
  }
168
168
  default:
@@ -246,7 +246,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
246
246
  else {
247
247
  throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
248
248
  'is not supported. Use variables instead of inline arguments to ' +
249
- 'overcome this limitation.') : new tsInvariant.InvariantError(58);
249
+ 'overcome this limitation.') : new tsInvariant.InvariantError(54);
250
250
  }
251
251
  }
252
252
  function storeKeyNameFromField(field, variables) {
@@ -380,16 +380,16 @@ function isInlineFragment(selection) {
380
380
  }
381
381
 
382
382
  function checkDocument(doc) {
383
- __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);
383
+ __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);
384
384
  var operations = doc.definitions
385
385
  .filter(function (d) { return d.kind !== 'FragmentDefinition'; })
386
386
  .map(function (definition) {
387
387
  if (definition.kind !== 'OperationDefinition') {
388
- throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(51);
388
+ throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(47);
389
389
  }
390
390
  return definition;
391
391
  });
392
- __DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 52);
392
+ __DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 48);
393
393
  return doc;
394
394
  }
395
395
  function getOperationDefinition(doc) {
@@ -408,14 +408,14 @@ function getFragmentDefinitions(doc) {
408
408
  }
409
409
  function getQueryDefinition(doc) {
410
410
  var queryDef = getOperationDefinition(doc);
411
- __DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 53);
411
+ __DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 49);
412
412
  return queryDef;
413
413
  }
414
414
  function getFragmentDefinition(doc) {
415
- __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);
416
- __DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 55);
415
+ __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);
416
+ __DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 51);
417
417
  var fragmentDef = doc.definitions[0];
418
- __DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 56);
418
+ __DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 52);
419
419
  return fragmentDef;
420
420
  }
421
421
  function getMainDefinition(queryDoc) {
@@ -438,7 +438,7 @@ function getMainDefinition(queryDoc) {
438
438
  if (fragmentDefinition) {
439
439
  return fragmentDefinition;
440
440
  }
441
- throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(57);
441
+ throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(53);
442
442
  }
443
443
  function getDefaultValues(definition) {
444
444
  var defaultValues = Object.create(null);
@@ -720,7 +720,7 @@ function removeClientSetsFromDocument(document) {
720
720
  return modifiedDoc;
721
721
  }
722
722
 
723
- var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
723
+ var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
724
724
  function mergeDeep() {
725
725
  var sources = [];
726
726
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -757,7 +757,7 @@ var DeepMerger = (function () {
757
757
  }
758
758
  if (isNonNullObject(source) && isNonNullObject(target)) {
759
759
  Object.keys(source).forEach(function (sourceKey) {
760
- if (hasOwnProperty$2.call(target, sourceKey)) {
760
+ if (hasOwnProperty$3.call(target, sourceKey)) {
761
761
  var targetValue = target[sourceKey];
762
762
  if (source[sourceKey] !== targetValue) {
763
763
  var result = _this.reconciler.apply(_this, tslib.__spreadArray([target, source, sourceKey], context));
@@ -937,7 +937,7 @@ var Concast = (function (_super) {
937
937
  var sub = _this.sub;
938
938
  if (sub !== null) {
939
939
  if (sub)
940
- Promise.resolve().then(function () { return sub.unsubscribe(); });
940
+ setTimeout(function () { return sub.unsubscribe(); });
941
941
  _this.sub = null;
942
942
  _this.latest = ["error", error];
943
943
  _this.reject(error);
@@ -1086,8 +1086,6 @@ function stringifyForDisplay(value) {
1086
1086
  }).split(JSON.stringify(undefId)).join("<undefined>");
1087
1087
  }
1088
1088
 
1089
- __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 59);
1090
-
1091
1089
  function fromError(errorValue) {
1092
1090
  return new zenObservableTs.Observable(function (observer) {
1093
1091
  observer.error(errorValue);
@@ -1143,7 +1141,7 @@ function validateOperation(operation) {
1143
1141
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
1144
1142
  var key = _a[_i];
1145
1143
  if (OPERATION_FIELDS.indexOf(key) < 0) {
1146
- throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(29);
1144
+ throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(26);
1147
1145
  }
1148
1146
  }
1149
1147
  return operation;
@@ -1266,7 +1264,7 @@ var ApolloLink = (function () {
1266
1264
  return ApolloLink.concat(this, next);
1267
1265
  };
1268
1266
  ApolloLink.prototype.request = function (operation, forward) {
1269
- throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(23);
1267
+ throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(21);
1270
1268
  };
1271
1269
  ApolloLink.prototype.onError = function (error, observer) {
1272
1270
  if (observer && observer.error) {
@@ -1292,9 +1290,9 @@ var concat = ApolloLink.concat;
1292
1290
 
1293
1291
  var execute = ApolloLink.execute;
1294
1292
 
1295
- var version = '3.4.6';
1293
+ var version = '3.4.10';
1296
1294
 
1297
- var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1295
+ var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1298
1296
  function parseAndCheckHttpResponse(operations) {
1299
1297
  return function (response) { return response
1300
1298
  .text()
@@ -1316,8 +1314,8 @@ function parseAndCheckHttpResponse(operations) {
1316
1314
  throwServerError(response, result, "Response not successful: Received status code " + response.status);
1317
1315
  }
1318
1316
  if (!Array.isArray(result) &&
1319
- !hasOwnProperty$1.call(result, 'data') &&
1320
- !hasOwnProperty$1.call(result, 'errors')) {
1317
+ !hasOwnProperty$2.call(result, 'data') &&
1318
+ !hasOwnProperty$2.call(result, 'errors')) {
1321
1319
  throwServerError(response, result, "Server response was missing for query '" + (Array.isArray(operations)
1322
1320
  ? operations.map(function (op) { return op.operationName; })
1323
1321
  : operations.operationName) + "'.");
@@ -1332,7 +1330,7 @@ var serializeFetchParameter = function (p, label) {
1332
1330
  serialized = JSON.stringify(p);
1333
1331
  }
1334
1332
  catch (e) {
1335
- var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(26);
1333
+ var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(23);
1336
1334
  parseError.parseError = e;
1337
1335
  throw parseError;
1338
1336
  }
@@ -1392,7 +1390,7 @@ function headersToLowerCase(headers) {
1392
1390
 
1393
1391
  var checkFetcher = function (fetcher) {
1394
1392
  if (!fetcher && typeof fetch === 'undefined') {
1395
- 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);
1393
+ 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);
1396
1394
  }
1397
1395
  };
1398
1396
 
@@ -1772,7 +1770,7 @@ var EntityStore = (function () {
1772
1770
  : newer;
1773
1771
  if (!incoming)
1774
1772
  return;
1775
- __DEV__ ? tsInvariant.invariant(typeof dataId === "string", "store.merge expects a string ID") : tsInvariant.invariant(typeof dataId === "string", 2);
1773
+ __DEV__ ? tsInvariant.invariant(typeof dataId === "string", "store.merge expects a string ID") : tsInvariant.invariant(typeof dataId === "string", 1);
1776
1774
  var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
1777
1775
  this.data[dataId] = merged;
1778
1776
  if (merged !== existing) {
@@ -2363,7 +2361,7 @@ var StoreReader = (function () {
2363
2361
  !context.store.has(objectOrReference.__ref)) {
2364
2362
  return {
2365
2363
  result: this.canon.empty,
2366
- missing: [missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object") : new tsInvariant.InvariantError(6), context)],
2364
+ missing: [missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object") : new tsInvariant.InvariantError(5), context)],
2367
2365
  };
2368
2366
  }
2369
2367
  var variables = context.variables, policies = context.policies, store = context.store;
@@ -2402,7 +2400,7 @@ var StoreReader = (function () {
2402
2400
  if (!addTypenameToDocument.added(selection)) {
2403
2401
  getMissing().push(missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Can't find field '" + selection.name.value + "' on " + (isReference(objectOrReference)
2404
2402
  ? objectOrReference.__ref + " object"
2405
- : "object " + JSON.stringify(objectOrReference, null, 2))) : new tsInvariant.InvariantError(7), context));
2403
+ : "object " + JSON.stringify(objectOrReference, null, 2))) : new tsInvariant.InvariantError(6), context));
2406
2404
  }
2407
2405
  }
2408
2406
  else if (Array.isArray(fieldValue)) {
@@ -2499,7 +2497,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
2499
2497
  var workSet_1 = new Set([fieldValue]);
2500
2498
  workSet_1.forEach(function (value) {
2501
2499
  if (isNonNullObject(value)) {
2502
- __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);
2500
+ __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);
2503
2501
  Object.values(value).forEach(workSet_1.add, workSet_1);
2504
2502
  }
2505
2503
  });
@@ -2538,12 +2536,12 @@ var StoreWriter = (function () {
2538
2536
  context: context,
2539
2537
  });
2540
2538
  if (!isReference(ref)) {
2541
- throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(9);
2539
+ throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(8);
2542
2540
  }
2543
2541
  context.incomingById.forEach(function (_a, dataId) {
2544
2542
  var fields = _a.fields, mergeTree = _a.mergeTree, selections = _a.selections;
2545
2543
  var entityRef = makeReference(dataId);
2546
- if (mergeTree.map.size) {
2544
+ if (mergeTree && mergeTree.map.size) {
2547
2545
  var applied = _this.applyMerges(mergeTree, entityRef, fields, context);
2548
2546
  if (isReference(applied)) {
2549
2547
  return;
@@ -2561,7 +2559,7 @@ var StoreWriter = (function () {
2561
2559
  }
2562
2560
  });
2563
2561
  var hasMergeFunction_1 = function (storeFieldName) {
2564
- var childTree = mergeTree.map.get(storeFieldName);
2562
+ var childTree = mergeTree && mergeTree.map.get(storeFieldName);
2565
2563
  return Boolean(childTree && childTree.info && childTree.info.merge);
2566
2564
  };
2567
2565
  Object.keys(fields).forEach(function (storeFieldName) {
@@ -2670,7 +2668,7 @@ var StoreWriter = (function () {
2670
2668
  else {
2671
2669
  context.incomingById.set(dataId, {
2672
2670
  fields: incomingFields,
2673
- mergeTree: mergeTree,
2671
+ mergeTree: mergeTreeIsEmpty(mergeTree) ? void 0 : mergeTree,
2674
2672
  selections: selections,
2675
2673
  });
2676
2674
  }
@@ -3035,7 +3033,7 @@ var Policies = (function () {
3035
3033
  var rootId = "ROOT_" + which.toUpperCase();
3036
3034
  var old = this.rootTypenamesById[rootId];
3037
3035
  if (typename !== old) {
3038
- __DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which, 3);
3036
+ __DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which, 2);
3039
3037
  if (old)
3040
3038
  delete this.rootIdsByTypename[old];
3041
3039
  this.rootIdsByTypename[typename] = rootId;
@@ -3279,7 +3277,7 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
3279
3277
  function makeMergeObjectsFunction(store) {
3280
3278
  return function mergeObjects(existing, incoming) {
3281
3279
  if (Array.isArray(existing) || Array.isArray(incoming)) {
3282
- throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(4);
3280
+ throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(3);
3283
3281
  }
3284
3282
  if (isNonNullObject(existing) &&
3285
3283
  isNonNullObject(incoming)) {
@@ -3360,24 +3358,27 @@ function makeAliasMap(selectionSet, fragmentMap) {
3360
3358
  }
3361
3359
  function computeKeyObject(response, specifier, strict, aliasMap) {
3362
3360
  var keyObj = Object.create(null);
3363
- var prevKey;
3361
+ var lastResponseKey;
3362
+ var lastActualKey;
3364
3363
  specifier.forEach(function (s) {
3365
3364
  if (Array.isArray(s)) {
3366
- if (typeof prevKey === "string") {
3365
+ if (typeof lastActualKey === "string" &&
3366
+ typeof lastResponseKey === "string") {
3367
3367
  var subsets = aliasMap && aliasMap.subsets;
3368
- var subset = subsets && subsets[prevKey];
3369
- keyObj[prevKey] = computeKeyObject(response[prevKey], s, strict, subset);
3368
+ var subset = subsets && subsets[lastActualKey];
3369
+ keyObj[lastActualKey] =
3370
+ computeKeyObject(response[lastResponseKey], s, strict, subset);
3370
3371
  }
3371
3372
  }
3372
3373
  else {
3373
3374
  var aliases = aliasMap && aliasMap.aliases;
3374
3375
  var responseName = aliases && aliases[s] || s;
3375
3376
  if (hasOwn.call(response, responseName)) {
3376
- keyObj[prevKey = s] = response[responseName];
3377
+ keyObj[lastActualKey = s] = response[lastResponseKey = responseName];
3377
3378
  }
3378
3379
  else {
3379
- __DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict, 5);
3380
- prevKey = void 0;
3380
+ __DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict, 4);
3381
+ lastResponseKey = lastActualKey = void 0;
3381
3382
  }
3382
3383
  }
3383
3384
  });
@@ -3669,7 +3670,6 @@ var InMemoryCache = (function (_super) {
3669
3670
  return InMemoryCache;
3670
3671
  }(ApolloCache));
3671
3672
 
3672
- __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 22);
3673
3673
  function isApolloError(err) {
3674
3674
  return err.hasOwnProperty('graphQLErrors');
3675
3675
  }
@@ -3721,6 +3721,7 @@ function isNetworkRequestInFlight(networkStatus) {
3721
3721
  return networkStatus ? networkStatus < 7 : false;
3722
3722
  }
3723
3723
 
3724
+ var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
3724
3725
  var warnedAboutUpdateQuery = false;
3725
3726
  var ObservableQuery = (function (_super) {
3726
3727
  tslib.__extends(ObservableQuery, _super);
@@ -3736,11 +3737,12 @@ var ObservableQuery = (function (_super) {
3736
3737
  catch (_a) { }
3737
3738
  var first = !_this.observers.size;
3738
3739
  _this.observers.add(observer);
3739
- if (_this.lastError) {
3740
- observer.error && observer.error(_this.lastError);
3740
+ var last = _this.last;
3741
+ if (last && last.error) {
3742
+ observer.error && observer.error(last.error);
3741
3743
  }
3742
- else if (_this.lastResult) {
3743
- observer.next && observer.next(_this.lastResult);
3744
+ else if (last && last.result) {
3745
+ observer.next && observer.next(last.result);
3744
3746
  }
3745
3747
  if (first) {
3746
3748
  _this.reobserve().catch(function () { });
@@ -3753,18 +3755,6 @@ var ObservableQuery = (function (_super) {
3753
3755
  }) || this;
3754
3756
  _this.observers = new Set();
3755
3757
  _this.subscriptions = new Set();
3756
- _this.observer = {
3757
- next: function (result) {
3758
- if (_this.lastError || _this.isDifferentFromLastResult(result)) {
3759
- _this.updateLastResult(result);
3760
- iterateObserversSafely(_this.observers, 'next', result);
3761
- }
3762
- },
3763
- error: function (error) {
3764
- _this.updateLastResult(tslib.__assign(tslib.__assign({}, _this.lastResult), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false }));
3765
- iterateObserversSafely(_this.observers, 'error', _this.lastError = error);
3766
- },
3767
- };
3768
3758
  _this.isTornDown = false;
3769
3759
  _this.options = options;
3770
3760
  _this.queryId = queryInfo.queryId || queryManager.generateQueryId();
@@ -3803,15 +3793,24 @@ var ObservableQuery = (function (_super) {
3803
3793
  };
3804
3794
  ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
3805
3795
  if (saveAsLastResult === void 0) { saveAsLastResult = true; }
3806
- var _a = this, lastResult = _a.lastResult, _b = _a.options.fetchPolicy, fetchPolicy = _b === void 0 ? "cache-first" : _b;
3796
+ var lastResult = this.getLastResult(true);
3807
3797
  var networkStatus = this.queryInfo.networkStatus ||
3808
3798
  (lastResult && lastResult.networkStatus) ||
3809
3799
  exports.NetworkStatus.ready;
3810
3800
  var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
3811
- if (!this.queryManager.transform(this.options.query).hasForcedResolvers) {
3801
+ var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
3802
+ var shouldReturnCachedData = lastResult || (fetchPolicy !== 'network-only' &&
3803
+ fetchPolicy !== 'no-cache' &&
3804
+ fetchPolicy !== 'standby');
3805
+ if (shouldReturnCachedData &&
3806
+ !this.queryManager.transform(this.options.query).hasForcedResolvers) {
3812
3807
  var diff = this.queryInfo.getDiff();
3813
- result.data = (diff.complete ||
3814
- this.options.returnPartialData) ? diff.result : void 0;
3808
+ if (diff.complete || this.options.returnPartialData) {
3809
+ result.data = diff.result;
3810
+ }
3811
+ if (equality.equal(result.data, {})) {
3812
+ result.data = void 0;
3813
+ }
3815
3814
  if (diff.complete) {
3816
3815
  if (result.networkStatus === exports.NetworkStatus.loading &&
3817
3816
  (fetchPolicy === 'cache-first' ||
@@ -3839,24 +3838,31 @@ var ObservableQuery = (function (_super) {
3839
3838
  return result;
3840
3839
  };
3841
3840
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult) {
3842
- return !equality.equal(this.lastResultSnapshot, newResult);
3841
+ return !this.last || !equality.equal(this.last.result, newResult);
3843
3842
  };
3844
- ObservableQuery.prototype.getLastResult = function () {
3845
- return this.lastResult;
3843
+ ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
3844
+ var last = this.last;
3845
+ if (last &&
3846
+ last[key] &&
3847
+ (!variablesMustMatch || equality.equal(last.variables, this.variables))) {
3848
+ return last[key];
3849
+ }
3850
+ };
3851
+ ObservableQuery.prototype.getLastResult = function (variablesMustMatch) {
3852
+ return this.getLast("result", variablesMustMatch);
3846
3853
  };
3847
- ObservableQuery.prototype.getLastError = function () {
3848
- return this.lastError;
3854
+ ObservableQuery.prototype.getLastError = function (variablesMustMatch) {
3855
+ return this.getLast("error", variablesMustMatch);
3849
3856
  };
3850
3857
  ObservableQuery.prototype.resetLastResults = function () {
3851
- delete this.lastResult;
3852
- delete this.lastResultSnapshot;
3853
- delete this.lastError;
3858
+ delete this.last;
3854
3859
  this.isTornDown = false;
3855
3860
  };
3856
3861
  ObservableQuery.prototype.resetQueryStoreErrors = function () {
3857
3862
  this.queryManager.resetErrors(this.queryId);
3858
3863
  };
3859
3864
  ObservableQuery.prototype.refetch = function (variables) {
3865
+ var _a;
3860
3866
  var reobserveOptions = {
3861
3867
  pollInterval: 0,
3862
3868
  };
@@ -3867,6 +3873,13 @@ var ObservableQuery = (function (_super) {
3867
3873
  else if (fetchPolicy !== 'cache-and-network') {
3868
3874
  reobserveOptions.fetchPolicy = 'network-only';
3869
3875
  }
3876
+ if (__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
3877
+ var queryDef = getQueryDefinition(this.options.query);
3878
+ var vars = queryDef.variableDefinitions;
3879
+ if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
3880
+ __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 })?");
3881
+ }
3882
+ }
3870
3883
  if (variables && !equality.equal(this.options.variables, variables)) {
3871
3884
  reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
3872
3885
  }
@@ -3963,12 +3976,10 @@ var ObservableQuery = (function (_super) {
3963
3976
  }, exports.NetworkStatus.setVariables);
3964
3977
  };
3965
3978
  ObservableQuery.prototype.updateQuery = function (mapFn) {
3966
- var _a;
3967
3979
  var queryManager = this.queryManager;
3968
3980
  var result = queryManager.cache.diff({
3969
3981
  query: this.options.query,
3970
3982
  variables: this.variables,
3971
- previousResult: (_a = this.lastResult) === null || _a === void 0 ? void 0 : _a.data,
3972
3983
  returnPartialData: true,
3973
3984
  optimistic: false,
3974
3985
  }).result;
@@ -4013,7 +4024,7 @@ var ObservableQuery = (function (_super) {
4013
4024
  pollingInfo.interval === pollInterval) {
4014
4025
  return;
4015
4026
  }
4016
- __DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 13);
4027
+ __DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 12);
4017
4028
  var info = pollingInfo || (this.pollingInfo = {});
4018
4029
  info.interval = pollInterval;
4019
4030
  var maybeFetch = function () {
@@ -4037,18 +4048,18 @@ var ObservableQuery = (function (_super) {
4037
4048
  };
4038
4049
  poll();
4039
4050
  };
4040
- ObservableQuery.prototype.updateLastResult = function (newResult) {
4041
- var previousResult = this.lastResult;
4042
- this.lastResult = newResult;
4043
- this.lastResultSnapshot = this.queryManager.assumeImmutableResults
4044
- ? newResult
4045
- : cloneDeep(newResult);
4051
+ ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
4052
+ if (variables === void 0) { variables = this.variables; }
4053
+ this.last = tslib.__assign(tslib.__assign({}, this.last), { result: this.queryManager.assumeImmutableResults
4054
+ ? newResult
4055
+ : cloneDeep(newResult), variables: variables });
4046
4056
  if (!isNonEmptyArray(newResult.errors)) {
4047
- delete this.lastError;
4057
+ delete this.last.error;
4048
4058
  }
4049
- return previousResult;
4059
+ return this.last;
4050
4060
  };
4051
4061
  ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
4062
+ var _this = this;
4052
4063
  this.isTornDown = false;
4053
4064
  var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
4054
4065
  newNetworkStatus === exports.NetworkStatus.fetchMore ||
@@ -4056,7 +4067,7 @@ var ObservableQuery = (function (_super) {
4056
4067
  var oldVariables = this.options.variables;
4057
4068
  var options = useDisposableConcast
4058
4069
  ? compact(this.options, newOptions)
4059
- : Object.assign(this.options, compact(newOptions));
4070
+ : assign(this.options, compact(newOptions));
4060
4071
  if (!useDisposableConcast) {
4061
4072
  this.updatePolling();
4062
4073
  if (newOptions &&
@@ -4069,18 +4080,39 @@ var ObservableQuery = (function (_super) {
4069
4080
  }
4070
4081
  }
4071
4082
  }
4083
+ var variables = options.variables && tslib.__assign({}, options.variables);
4072
4084
  var concast = this.fetch(options, newNetworkStatus);
4085
+ var observer = {
4086
+ next: function (result) {
4087
+ _this.reportResult(result, variables);
4088
+ },
4089
+ error: function (error) {
4090
+ _this.reportError(error, variables);
4091
+ },
4092
+ };
4073
4093
  if (!useDisposableConcast) {
4074
- if (this.concast) {
4094
+ if (this.concast && this.observer) {
4075
4095
  this.concast.removeObserver(this.observer, true);
4076
4096
  }
4077
4097
  this.concast = concast;
4098
+ this.observer = observer;
4078
4099
  }
4079
- concast.addObserver(this.observer);
4100
+ concast.addObserver(observer);
4080
4101
  return concast.promise;
4081
4102
  };
4082
4103
  ObservableQuery.prototype.observe = function () {
4083
- this.observer.next(this.getCurrentResult(false));
4104
+ this.reportResult(this.getCurrentResult(false), this.variables);
4105
+ };
4106
+ ObservableQuery.prototype.reportResult = function (result, variables) {
4107
+ if (this.getLastError() || this.isDifferentFromLastResult(result)) {
4108
+ this.updateLastResult(result, variables);
4109
+ iterateObserversSafely(this.observers, 'next', result);
4110
+ }
4111
+ };
4112
+ ObservableQuery.prototype.reportError = function (error, variables) {
4113
+ var errorResult = tslib.__assign(tslib.__assign({}, this.getLastResult()), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false });
4114
+ this.updateLastResult(errorResult, variables);
4115
+ iterateObserversSafely(this.observers, 'error', this.last.error = error);
4084
4116
  };
4085
4117
  ObservableQuery.prototype.hasObservers = function () {
4086
4118
  return this.observers.size > 0;
@@ -4088,9 +4120,10 @@ var ObservableQuery = (function (_super) {
4088
4120
  ObservableQuery.prototype.tearDownQuery = function () {
4089
4121
  if (this.isTornDown)
4090
4122
  return;
4091
- if (this.concast) {
4123
+ if (this.concast && this.observer) {
4092
4124
  this.concast.removeObserver(this.observer);
4093
4125
  delete this.concast;
4126
+ delete this.observer;
4094
4127
  }
4095
4128
  this.stopPolling();
4096
4129
  this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
@@ -4288,7 +4321,7 @@ var LocalState = (function () {
4288
4321
  }
4289
4322
  else {
4290
4323
  fragment = fragmentMap[selection.name.value];
4291
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 12);
4324
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 11);
4292
4325
  }
4293
4326
  if (fragment && fragment.typeCondition) {
4294
4327
  typeCondition = fragment.typeCondition.name.value;
@@ -4674,7 +4707,7 @@ var QueryManager = (function () {
4674
4707
  this.queries.forEach(function (_info, queryId) {
4675
4708
  _this.stopQueryNoBroadcast(queryId);
4676
4709
  });
4677
- this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(14));
4710
+ this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(13));
4678
4711
  };
4679
4712
  QueryManager.prototype.cancelPendingFetches = function (error) {
4680
4713
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -4687,10 +4720,10 @@ var QueryManager = (function () {
4687
4720
  return tslib.__generator(this, function (_f) {
4688
4721
  switch (_f.label) {
4689
4722
  case 0:
4690
- __DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 15);
4723
+ __DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 14);
4691
4724
  __DEV__ ? tsInvariant.invariant(fetchPolicy === 'network-only' ||
4692
4725
  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' ||
4693
- fetchPolicy === 'no-cache', 16);
4726
+ fetchPolicy === 'no-cache', 15);
4694
4727
  mutationId = this.generateMutationId();
4695
4728
  mutation = this.transform(mutation).document;
4696
4729
  variables = this.getVariables(mutation, variables);
@@ -4975,10 +5008,10 @@ var QueryManager = (function () {
4975
5008
  var _this = this;
4976
5009
  if (queryId === void 0) { queryId = this.generateQueryId(); }
4977
5010
  __DEV__ ? tsInvariant.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
4978
- 'in the query option.') : tsInvariant.invariant(options.query, 17);
4979
- __DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 18);
4980
- __DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 19);
4981
- __DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 20);
5011
+ 'in the query option.') : tsInvariant.invariant(options.query, 16);
5012
+ __DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 17);
5013
+ __DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 18);
5014
+ __DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 19);
4982
5015
  return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
4983
5016
  };
4984
5017
  QueryManager.prototype.generateQueryId = function () {
@@ -5000,7 +5033,7 @@ var QueryManager = (function () {
5000
5033
  queryInfo.stop();
5001
5034
  };
5002
5035
  QueryManager.prototype.clearStore = function () {
5003
- this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(21));
5036
+ this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(20));
5004
5037
  this.queries.forEach(function (queryInfo) {
5005
5038
  if (queryInfo.observableQuery) {
5006
5039
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -5275,7 +5308,7 @@ var QueryManager = (function () {
5275
5308
  return _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
5276
5309
  };
5277
5310
  this.fetchCancelFns.set(queryId, function (reason) {
5278
- Promise.resolve().then(function () { return concast.cancel(reason); });
5311
+ setTimeout(function () { return concast.cancel(reason); });
5279
5312
  });
5280
5313
  var concast = new Concast(this.transform(normalized.query).hasClientExports
5281
5314
  ? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
@@ -5493,7 +5526,7 @@ var ApolloClient = (function () {
5493
5526
  if (!cache) {
5494
5527
  throw __DEV__ ? new tsInvariant.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
5495
5528
  "in the options object. \n" +
5496
- "For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(10);
5529
+ "For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(9);
5497
5530
  }
5498
5531
  this.link = link;
5499
5532
  this.cache = cache;
@@ -5589,7 +5622,7 @@ var ApolloClient = (function () {
5589
5622
  __DEV__ ? tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
5590
5623
  'client.query can only return a single result. Please use client.watchQuery ' +
5591
5624
  'to receive multiple results from the cache and the network, or consider ' +
5592
- 'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 11);
5625
+ 'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 10);
5593
5626
  if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
5594
5627
  options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
5595
5628
  }