@apollo/client 3.4.7 → 3.4.11

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 (227) hide show
  1. package/README.md +2 -2
  2. package/apollo-client.cjs.js +155 -156
  3. package/apollo-client.cjs.js.map +1 -1
  4. package/apollo-core.cjs.js +140 -103
  5. package/apollo-core.cjs.js.map +1 -1
  6. package/apollo-core.cjs.min.js +1 -1
  7. package/cache/cache.cjs.js +29 -28
  8. package/cache/cache.cjs.js.map +1 -1
  9. package/cache/index.d.ts +1 -0
  10. package/cache/index.d.ts.map +1 -1
  11. package/cache/index.js +1 -3
  12. package/cache/index.js.map +1 -1
  13. package/cache/inmemory/entityStore.js +2 -2
  14. package/cache/inmemory/entityStore.js.map +1 -1
  15. package/cache/inmemory/object-canon.d.ts +1 -0
  16. package/cache/inmemory/object-canon.d.ts.map +1 -1
  17. package/cache/inmemory/object-canon.js +1 -0
  18. package/cache/inmemory/object-canon.js.map +1 -1
  19. package/cache/inmemory/policies.d.ts.map +1 -1
  20. package/cache/inmemory/policies.js +13 -10
  21. package/cache/inmemory/policies.js.map +1 -1
  22. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  23. package/cache/inmemory/readFromStore.js +4 -4
  24. package/cache/inmemory/readFromStore.js.map +1 -1
  25. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  26. package/cache/inmemory/writeToStore.js +2 -2
  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 +1 -1
  77. package/link/persisted-queries/index.d.ts.map +1 -1
  78. package/link/persisted-queries/index.js +4 -4
  79. package/link/persisted-queries/index.js.map +1 -1
  80. package/link/persisted-queries/persisted-queries.cjs.js +8 -5
  81. package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
  82. package/link/utils/index.d.ts +1 -0
  83. package/link/utils/index.d.ts.map +1 -1
  84. package/link/utils/index.js +1 -0
  85. package/link/utils/index.js.map +1 -1
  86. package/link/utils/toPromise.d.ts.map +1 -1
  87. package/link/utils/toPromise.js +1 -1
  88. package/link/utils/toPromise.js.map +1 -1
  89. package/link/utils/utils.cjs.js +3 -3
  90. package/link/utils/utils.cjs.js.map +1 -1
  91. package/link/utils/validateOperation.d.ts.map +1 -1
  92. package/link/utils/validateOperation.js +2 -2
  93. package/link/utils/validateOperation.js.map +1 -1
  94. package/package.json +11 -11
  95. package/react/context/ApolloConsumer.d.ts.map +1 -1
  96. package/react/context/ApolloConsumer.js +2 -2
  97. package/react/context/ApolloConsumer.js.map +1 -1
  98. package/react/context/ApolloProvider.d.ts.map +1 -1
  99. package/react/context/ApolloProvider.js +2 -2
  100. package/react/context/ApolloProvider.js.map +1 -1
  101. package/react/context/context.cjs.js +5 -5
  102. package/react/context/context.cjs.js.map +1 -1
  103. package/react/context/index.d.ts +1 -0
  104. package/react/context/index.d.ts.map +1 -1
  105. package/react/context/index.js +1 -0
  106. package/react/context/index.js.map +1 -1
  107. package/react/data/OperationData.d.ts.map +1 -1
  108. package/react/data/OperationData.js +3 -3
  109. package/react/data/OperationData.js.map +1 -1
  110. package/react/data/QueryData.d.ts.map +1 -1
  111. package/react/data/QueryData.js +9 -11
  112. package/react/data/QueryData.js.map +1 -1
  113. package/react/data/data.cjs.js +14 -16
  114. package/react/data/data.cjs.js.map +1 -1
  115. package/react/data/index.d.ts +1 -0
  116. package/react/data/index.d.ts.map +1 -1
  117. package/react/data/index.js +1 -0
  118. package/react/data/index.js.map +1 -1
  119. package/react/hoc/hoc-utils.d.ts.map +1 -1
  120. package/react/hoc/hoc-utils.js +2 -2
  121. package/react/hoc/hoc-utils.js.map +1 -1
  122. package/react/hoc/hoc.cjs.js +5 -5
  123. package/react/hoc/hoc.cjs.js.map +1 -1
  124. package/react/hoc/index.d.ts +1 -0
  125. package/react/hoc/index.d.ts.map +1 -1
  126. package/react/hoc/index.js +1 -0
  127. package/react/hoc/index.js.map +1 -1
  128. package/react/hoc/withApollo.d.ts.map +1 -1
  129. package/react/hoc/withApollo.js +2 -2
  130. package/react/hoc/withApollo.js.map +1 -1
  131. package/react/hooks/hooks.cjs.js +3 -3
  132. package/react/hooks/hooks.cjs.js.map +1 -1
  133. package/react/hooks/index.d.ts +1 -0
  134. package/react/hooks/index.d.ts.map +1 -1
  135. package/react/hooks/index.js +1 -0
  136. package/react/hooks/index.js.map +1 -1
  137. package/react/hooks/useApolloClient.d.ts.map +1 -1
  138. package/react/hooks/useApolloClient.js +2 -2
  139. package/react/hooks/useApolloClient.js.map +1 -1
  140. package/react/hooks/useSubscription.d.ts +1 -0
  141. package/react/hooks/useSubscription.d.ts.map +1 -1
  142. package/react/hooks/useSubscription.js +1 -0
  143. package/react/hooks/useSubscription.js.map +1 -1
  144. package/react/hooks/utils/useAfterFastRefresh.d.ts +1 -0
  145. package/react/hooks/utils/useAfterFastRefresh.d.ts.map +1 -1
  146. package/react/hooks/utils/useAfterFastRefresh.js +1 -0
  147. package/react/hooks/utils/useAfterFastRefresh.js.map +1 -1
  148. package/react/hooks/utils/useBaseQuery.d.ts +1 -0
  149. package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
  150. package/react/hooks/utils/useBaseQuery.js +1 -0
  151. package/react/hooks/utils/useBaseQuery.js.map +1 -1
  152. package/react/index.d.ts +1 -0
  153. package/react/index.d.ts.map +1 -1
  154. package/react/index.js +1 -3
  155. package/react/index.js.map +1 -1
  156. package/react/parser/index.d.ts.map +1 -1
  157. package/react/parser/index.js +5 -5
  158. package/react/parser/index.js.map +1 -1
  159. package/react/parser/parser.cjs.js +10 -10
  160. package/react/parser/parser.cjs.js.map +1 -1
  161. package/react/react.cjs.js +2 -3
  162. package/react/react.cjs.js.map +1 -1
  163. package/testing/index.d.ts +1 -0
  164. package/testing/index.d.ts.map +1 -1
  165. package/testing/index.js +1 -3
  166. package/testing/index.js.map +1 -1
  167. package/testing/testing.cjs.js +3 -5
  168. package/testing/testing.cjs.js.map +1 -1
  169. package/utilities/common/mergeDeep.js +1 -1
  170. package/utilities/common/mergeDeep.js.map +1 -1
  171. package/utilities/globals/DEV.js +2 -2
  172. package/utilities/globals/DEV.js.map +1 -1
  173. package/utilities/{common → globals}/global.d.ts +0 -0
  174. package/utilities/globals/global.d.ts.map +1 -0
  175. package/utilities/{common → globals}/global.js +0 -0
  176. package/utilities/globals/global.js.map +1 -0
  177. package/utilities/globals/globals.cjs.js +57 -0
  178. package/utilities/globals/globals.cjs.js.map +1 -0
  179. package/utilities/globals/index.d.ts +5 -2
  180. package/utilities/globals/index.d.ts.map +1 -1
  181. package/utilities/globals/index.js +8 -1
  182. package/utilities/globals/index.js.map +1 -1
  183. package/utilities/{common → globals}/maybe.d.ts +0 -0
  184. package/utilities/globals/maybe.d.ts.map +1 -0
  185. package/utilities/{common → globals}/maybe.js +0 -0
  186. package/utilities/globals/maybe.js.map +1 -0
  187. package/utilities/globals/package.json +7 -0
  188. package/utilities/graphql/directives.d.ts.map +1 -1
  189. package/utilities/graphql/directives.js +5 -5
  190. package/utilities/graphql/directives.js.map +1 -1
  191. package/utilities/graphql/fragments.d.ts.map +1 -1
  192. package/utilities/graphql/fragments.js +5 -5
  193. package/utilities/graphql/fragments.js.map +1 -1
  194. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  195. package/utilities/graphql/getFromAST.js +9 -9
  196. package/utilities/graphql/getFromAST.js.map +1 -1
  197. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  198. package/utilities/graphql/storeUtils.js +2 -2
  199. package/utilities/graphql/storeUtils.js.map +1 -1
  200. package/utilities/graphql/transform.d.ts.map +1 -1
  201. package/utilities/graphql/transform.js +2 -2
  202. package/utilities/graphql/transform.js.map +1 -1
  203. package/utilities/index.d.ts +1 -3
  204. package/utilities/index.d.ts.map +1 -1
  205. package/utilities/index.js +1 -5
  206. package/utilities/index.js.map +1 -1
  207. package/utilities/observables/Concast.js +1 -1
  208. package/utilities/observables/Concast.js.map +1 -1
  209. package/utilities/package.json +1 -3
  210. package/utilities/policies/pagination.js +2 -2
  211. package/utilities/policies/pagination.js.map +1 -1
  212. package/utilities/testing/mocking/mockFetch.js +1 -1
  213. package/utilities/testing/mocking/mockFetch.js.map +1 -1
  214. package/utilities/testing/mocking/mockLink.d.ts.map +1 -1
  215. package/utilities/testing/mocking/mockLink.js +2 -2
  216. package/utilities/testing/mocking/mockLink.js.map +1 -1
  217. package/utilities/testing/mocking/mockWatchQuery.js +1 -1
  218. package/utilities/testing/mocking/mockWatchQuery.js.map +1 -1
  219. package/utilities/testing/observableToPromise.js +1 -1
  220. package/utilities/testing/observableToPromise.js.map +1 -1
  221. package/utilities/utilities.cjs.js +30 -71
  222. package/utilities/utilities.cjs.js.map +1 -1
  223. package/version.js +1 -1
  224. package/utilities/common/global.d.ts.map +0 -1
  225. package/utilities/common/global.js.map +0 -1
  226. package/utilities/common/maybe.d.ts.map +0 -1
  227. package/utilities/common/maybe.js.map +0 -1
@@ -50,7 +50,11 @@ function removeTemporaryGlobals() {
50
50
  return process$1.remove();
51
51
  }
52
52
 
53
+ function checkDEV() {
54
+ __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 38);
55
+ }
53
56
  removeTemporaryGlobals();
57
+ checkDEV();
54
58
 
55
59
  function shouldInclude(_a, variables) {
56
60
  var directives = _a.directives;
@@ -62,7 +66,7 @@ function shouldInclude(_a, variables) {
62
66
  var evaledValue = false;
63
67
  if (ifArgument.value.kind === 'Variable') {
64
68
  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);
69
+ __DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : tsInvariant.invariant(evaledValue !== void 0, 39);
66
70
  }
67
71
  else {
68
72
  evaledValue = ifArgument.value.value;
@@ -99,13 +103,13 @@ function getInclusionDirectives(directives) {
99
103
  return;
100
104
  var directiveArguments = directive.arguments;
101
105
  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);
106
+ __DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 40);
103
107
  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);
108
+ __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
109
  var ifValue = ifArgument.value;
106
110
  __DEV__ ? tsInvariant.invariant(ifValue &&
107
111
  (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);
112
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 42);
109
113
  result.push({ directive: directive, ifArgument: ifArgument });
110
114
  });
111
115
  }
@@ -118,14 +122,14 @@ function getFragmentQueryDocument(document, fragmentName) {
118
122
  document.definitions.forEach(function (definition) {
119
123
  if (definition.kind === 'OperationDefinition') {
120
124
  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);
125
+ 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(43);
122
126
  }
123
127
  if (definition.kind === 'FragmentDefinition') {
124
128
  fragments.push(definition);
125
129
  }
126
130
  });
127
131
  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);
132
+ __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
133
  actualFragmentName = fragments[0].name.value;
130
134
  }
131
135
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -145,7 +149,7 @@ function getFragmentQueryDocument(document, fragmentName) {
145
149
  ],
146
150
  },
147
151
  }
148
- ], document.definitions) });
152
+ ], document.definitions, true) });
149
153
  return query;
150
154
  }
151
155
  function createFragmentMap(fragments) {
@@ -162,7 +166,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
162
166
  return selection;
163
167
  case 'FragmentSpread': {
164
168
  var fragment = fragmentMap && fragmentMap[selection.name.value];
165
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 49);
169
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value + ".") : tsInvariant.invariant(fragment, 45);
166
170
  return fragment;
167
171
  }
168
172
  default:
@@ -246,7 +250,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
246
250
  else {
247
251
  throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"" + name.value + "\" of kind \"" + value.kind + "\"" +
248
252
  'is not supported. Use variables instead of inline arguments to ' +
249
- 'overcome this limitation.') : new tsInvariant.InvariantError(58);
253
+ 'overcome this limitation.') : new tsInvariant.InvariantError(54);
250
254
  }
251
255
  }
252
256
  function storeKeyNameFromField(field, variables) {
@@ -380,16 +384,16 @@ function isInlineFragment(selection) {
380
384
  }
381
385
 
382
386
  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);
387
+ __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
388
  var operations = doc.definitions
385
389
  .filter(function (d) { return d.kind !== 'FragmentDefinition'; })
386
390
  .map(function (definition) {
387
391
  if (definition.kind !== 'OperationDefinition') {
388
- throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(51);
392
+ throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\"") : new tsInvariant.InvariantError(47);
389
393
  }
390
394
  return definition;
391
395
  });
392
- __DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 52);
396
+ __DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations") : tsInvariant.invariant(operations.length <= 1, 48);
393
397
  return doc;
394
398
  }
395
399
  function getOperationDefinition(doc) {
@@ -408,14 +412,14 @@ function getFragmentDefinitions(doc) {
408
412
  }
409
413
  function getQueryDefinition(doc) {
410
414
  var queryDef = getOperationDefinition(doc);
411
- __DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 53);
415
+ __DEV__ ? tsInvariant.invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.') : tsInvariant.invariant(queryDef && queryDef.operation === 'query', 49);
412
416
  return queryDef;
413
417
  }
414
418
  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);
419
+ __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);
420
+ __DEV__ ? tsInvariant.invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.') : tsInvariant.invariant(doc.definitions.length <= 1, 51);
417
421
  var fragmentDef = doc.definitions[0];
418
- __DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 56);
422
+ __DEV__ ? tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.') : tsInvariant.invariant(fragmentDef.kind === 'FragmentDefinition', 52);
419
423
  return fragmentDef;
420
424
  }
421
425
  function getMainDefinition(queryDoc) {
@@ -438,7 +442,7 @@ function getMainDefinition(queryDoc) {
438
442
  if (fragmentDefinition) {
439
443
  return fragmentDefinition;
440
444
  }
441
- throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(57);
445
+ throw __DEV__ ? new tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.') : new tsInvariant.InvariantError(53);
442
446
  }
443
447
  function getDefaultValues(definition) {
444
448
  var defaultValues = Object.create(null);
@@ -581,7 +585,7 @@ var addTypenameToDocument = Object.assign(function (doc) {
581
585
  field.directives.some(function (d) { return d.name.value === 'export'; })) {
582
586
  return;
583
587
  }
584
- return tslib.__assign(tslib.__assign({}, node), { selections: tslib.__spreadArray(tslib.__spreadArray([], selections), [TYPENAME_FIELD]) });
588
+ return tslib.__assign(tslib.__assign({}, node), { selections: tslib.__spreadArray(tslib.__spreadArray([], selections, true), [TYPENAME_FIELD], false) });
585
589
  },
586
590
  },
587
591
  });
@@ -720,7 +724,7 @@ function removeClientSetsFromDocument(document) {
720
724
  return modifiedDoc;
721
725
  }
722
726
 
723
- var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
727
+ var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
724
728
  function mergeDeep() {
725
729
  var sources = [];
726
730
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -757,10 +761,10 @@ var DeepMerger = (function () {
757
761
  }
758
762
  if (isNonNullObject(source) && isNonNullObject(target)) {
759
763
  Object.keys(source).forEach(function (sourceKey) {
760
- if (hasOwnProperty$2.call(target, sourceKey)) {
764
+ if (hasOwnProperty$3.call(target, sourceKey)) {
761
765
  var targetValue = target[sourceKey];
762
766
  if (source[sourceKey] !== targetValue) {
763
- var result = _this.reconciler.apply(_this, tslib.__spreadArray([target, source, sourceKey], context));
767
+ var result = _this.reconciler.apply(_this, tslib.__spreadArray([target, source, sourceKey], context, false));
764
768
  if (result !== targetValue) {
765
769
  target = _this.shallowCopyForMerge(target);
766
770
  target[sourceKey] = result;
@@ -937,7 +941,7 @@ var Concast = (function (_super) {
937
941
  var sub = _this.sub;
938
942
  if (sub !== null) {
939
943
  if (sub)
940
- Promise.resolve().then(function () { return sub.unsubscribe(); });
944
+ setTimeout(function () { return sub.unsubscribe(); });
941
945
  _this.sub = null;
942
946
  _this.latest = ["error", error];
943
947
  _this.reject(error);
@@ -1086,8 +1090,6 @@ function stringifyForDisplay(value) {
1086
1090
  }).split(JSON.stringify(undefId)).join("<undefined>");
1087
1091
  }
1088
1092
 
1089
- __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 59);
1090
-
1091
1093
  function fromError(errorValue) {
1092
1094
  return new zenObservableTs.Observable(function (observer) {
1093
1095
  observer.error(errorValue);
@@ -1143,7 +1145,7 @@ function validateOperation(operation) {
1143
1145
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
1144
1146
  var key = _a[_i];
1145
1147
  if (OPERATION_FIELDS.indexOf(key) < 0) {
1146
- throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(29);
1148
+ throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: " + key) : new tsInvariant.InvariantError(26);
1147
1149
  }
1148
1150
  }
1149
1151
  return operation;
@@ -1266,7 +1268,7 @@ var ApolloLink = (function () {
1266
1268
  return ApolloLink.concat(this, next);
1267
1269
  };
1268
1270
  ApolloLink.prototype.request = function (operation, forward) {
1269
- throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(23);
1271
+ throw __DEV__ ? new tsInvariant.InvariantError('request is not implemented') : new tsInvariant.InvariantError(21);
1270
1272
  };
1271
1273
  ApolloLink.prototype.onError = function (error, observer) {
1272
1274
  if (observer && observer.error) {
@@ -1292,9 +1294,9 @@ var concat = ApolloLink.concat;
1292
1294
 
1293
1295
  var execute = ApolloLink.execute;
1294
1296
 
1295
- var version = '3.4.7';
1297
+ var version = '3.4.11';
1296
1298
 
1297
- var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1299
+ var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1298
1300
  function parseAndCheckHttpResponse(operations) {
1299
1301
  return function (response) { return response
1300
1302
  .text()
@@ -1316,8 +1318,8 @@ function parseAndCheckHttpResponse(operations) {
1316
1318
  throwServerError(response, result, "Response not successful: Received status code " + response.status);
1317
1319
  }
1318
1320
  if (!Array.isArray(result) &&
1319
- !hasOwnProperty$1.call(result, 'data') &&
1320
- !hasOwnProperty$1.call(result, 'errors')) {
1321
+ !hasOwnProperty$2.call(result, 'data') &&
1322
+ !hasOwnProperty$2.call(result, 'errors')) {
1321
1323
  throwServerError(response, result, "Server response was missing for query '" + (Array.isArray(operations)
1322
1324
  ? operations.map(function (op) { return op.operationName; })
1323
1325
  : operations.operationName) + "'.");
@@ -1332,7 +1334,7 @@ var serializeFetchParameter = function (p, label) {
1332
1334
  serialized = JSON.stringify(p);
1333
1335
  }
1334
1336
  catch (e) {
1335
- var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(26);
1337
+ var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message) : new tsInvariant.InvariantError(23);
1336
1338
  parseError.parseError = e;
1337
1339
  throw parseError;
1338
1340
  }
@@ -1392,7 +1394,7 @@ function headersToLowerCase(headers) {
1392
1394
 
1393
1395
  var checkFetcher = function (fetcher) {
1394
1396
  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);
1397
+ 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
1398
  }
1397
1399
  };
1398
1400
 
@@ -1772,7 +1774,7 @@ var EntityStore = (function () {
1772
1774
  : newer;
1773
1775
  if (!incoming)
1774
1776
  return;
1775
- __DEV__ ? tsInvariant.invariant(typeof dataId === "string", "store.merge expects a string ID") : tsInvariant.invariant(typeof dataId === "string", 2);
1777
+ __DEV__ ? tsInvariant.invariant(typeof dataId === "string", "store.merge expects a string ID") : tsInvariant.invariant(typeof dataId === "string", 1);
1776
1778
  var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
1777
1779
  this.data[dataId] = merged;
1778
1780
  if (merged !== existing) {
@@ -2363,7 +2365,7 @@ var StoreReader = (function () {
2363
2365
  !context.store.has(objectOrReference.__ref)) {
2364
2366
  return {
2365
2367
  result: this.canon.empty,
2366
- missing: [missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object") : new tsInvariant.InvariantError(6), context)],
2368
+ missing: [missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object") : new tsInvariant.InvariantError(5), context)],
2367
2369
  };
2368
2370
  }
2369
2371
  var variables = context.variables, policies = context.policies, store = context.store;
@@ -2402,7 +2404,7 @@ var StoreReader = (function () {
2402
2404
  if (!addTypenameToDocument.added(selection)) {
2403
2405
  getMissing().push(missingFromInvariant(__DEV__ ? new tsInvariant.InvariantError("Can't find field '" + selection.name.value + "' on " + (isReference(objectOrReference)
2404
2406
  ? objectOrReference.__ref + " object"
2405
- : "object " + JSON.stringify(objectOrReference, null, 2))) : new tsInvariant.InvariantError(7), context));
2407
+ : "object " + JSON.stringify(objectOrReference, null, 2))) : new tsInvariant.InvariantError(6), context));
2406
2408
  }
2407
2409
  }
2408
2410
  else if (Array.isArray(fieldValue)) {
@@ -2499,7 +2501,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
2499
2501
  var workSet_1 = new Set([fieldValue]);
2500
2502
  workSet_1.forEach(function (value) {
2501
2503
  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);
2504
+ __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
2505
  Object.values(value).forEach(workSet_1.add, workSet_1);
2504
2506
  }
2505
2507
  });
@@ -2538,7 +2540,7 @@ var StoreWriter = (function () {
2538
2540
  context: context,
2539
2541
  });
2540
2542
  if (!isReference(ref)) {
2541
- throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(9);
2543
+ throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result)) : new tsInvariant.InvariantError(8);
2542
2544
  }
2543
2545
  context.incomingById.forEach(function (_a, dataId) {
2544
2546
  var fields = _a.fields, mergeTree = _a.mergeTree, selections = _a.selections;
@@ -3035,7 +3037,7 @@ var Policies = (function () {
3035
3037
  var rootId = "ROOT_" + which.toUpperCase();
3036
3038
  var old = this.rootTypenamesById[rootId];
3037
3039
  if (typename !== old) {
3038
- __DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which, 3);
3040
+ __DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root " + which + " __typename more than once") : tsInvariant.invariant(!old || old === which, 2);
3039
3041
  if (old)
3040
3042
  delete this.rootIdsByTypename[old];
3041
3043
  this.rootIdsByTypename[typename] = rootId;
@@ -3279,7 +3281,7 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
3279
3281
  function makeMergeObjectsFunction(store) {
3280
3282
  return function mergeObjects(existing, incoming) {
3281
3283
  if (Array.isArray(existing) || Array.isArray(incoming)) {
3282
- throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(4);
3284
+ throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(3);
3283
3285
  }
3284
3286
  if (isNonNullObject(existing) &&
3285
3287
  isNonNullObject(incoming)) {
@@ -3360,24 +3362,27 @@ function makeAliasMap(selectionSet, fragmentMap) {
3360
3362
  }
3361
3363
  function computeKeyObject(response, specifier, strict, aliasMap) {
3362
3364
  var keyObj = Object.create(null);
3363
- var prevKey;
3365
+ var lastResponseKey;
3366
+ var lastActualKey;
3364
3367
  specifier.forEach(function (s) {
3365
3368
  if (Array.isArray(s)) {
3366
- if (typeof prevKey === "string") {
3369
+ if (typeof lastActualKey === "string" &&
3370
+ typeof lastResponseKey === "string") {
3367
3371
  var subsets = aliasMap && aliasMap.subsets;
3368
- var subset = subsets && subsets[prevKey];
3369
- keyObj[prevKey] = computeKeyObject(response[prevKey], s, strict, subset);
3372
+ var subset = subsets && subsets[lastActualKey];
3373
+ keyObj[lastActualKey] =
3374
+ computeKeyObject(response[lastResponseKey], s, strict, subset);
3370
3375
  }
3371
3376
  }
3372
3377
  else {
3373
3378
  var aliases = aliasMap && aliasMap.aliases;
3374
3379
  var responseName = aliases && aliases[s] || s;
3375
3380
  if (hasOwn.call(response, responseName)) {
3376
- keyObj[prevKey = s] = response[responseName];
3381
+ keyObj[lastActualKey = s] = response[lastResponseKey = responseName];
3377
3382
  }
3378
3383
  else {
3379
- __DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict, 5);
3380
- prevKey = void 0;
3384
+ __DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict, 4);
3385
+ lastResponseKey = lastActualKey = void 0;
3381
3386
  }
3382
3387
  }
3383
3388
  });
@@ -3669,7 +3674,6 @@ var InMemoryCache = (function (_super) {
3669
3674
  return InMemoryCache;
3670
3675
  }(ApolloCache));
3671
3676
 
3672
- __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 22);
3673
3677
  function isApolloError(err) {
3674
3678
  return err.hasOwnProperty('graphQLErrors');
3675
3679
  }
@@ -3721,6 +3725,7 @@ function isNetworkRequestInFlight(networkStatus) {
3721
3725
  return networkStatus ? networkStatus < 7 : false;
3722
3726
  }
3723
3727
 
3728
+ var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
3724
3729
  var warnedAboutUpdateQuery = false;
3725
3730
  var ObservableQuery = (function (_super) {
3726
3731
  tslib.__extends(ObservableQuery, _super);
@@ -3736,11 +3741,12 @@ var ObservableQuery = (function (_super) {
3736
3741
  catch (_a) { }
3737
3742
  var first = !_this.observers.size;
3738
3743
  _this.observers.add(observer);
3739
- if (_this.lastError) {
3740
- observer.error && observer.error(_this.lastError);
3744
+ var last = _this.last;
3745
+ if (last && last.error) {
3746
+ observer.error && observer.error(last.error);
3741
3747
  }
3742
- else if (_this.lastResult) {
3743
- observer.next && observer.next(_this.lastResult);
3748
+ else if (last && last.result) {
3749
+ observer.next && observer.next(last.result);
3744
3750
  }
3745
3751
  if (first) {
3746
3752
  _this.reobserve().catch(function () { });
@@ -3753,18 +3759,6 @@ var ObservableQuery = (function (_super) {
3753
3759
  }) || this;
3754
3760
  _this.observers = new Set();
3755
3761
  _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
3762
  _this.isTornDown = false;
3769
3763
  _this.options = options;
3770
3764
  _this.queryId = queryInfo.queryId || queryManager.generateQueryId();
@@ -3803,15 +3797,24 @@ var ObservableQuery = (function (_super) {
3803
3797
  };
3804
3798
  ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
3805
3799
  if (saveAsLastResult === void 0) { saveAsLastResult = true; }
3806
- var _a = this, lastResult = _a.lastResult, _b = _a.options.fetchPolicy, fetchPolicy = _b === void 0 ? "cache-first" : _b;
3800
+ var lastResult = this.getLastResult(true);
3807
3801
  var networkStatus = this.queryInfo.networkStatus ||
3808
3802
  (lastResult && lastResult.networkStatus) ||
3809
3803
  exports.NetworkStatus.ready;
3810
3804
  var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
3811
- if (!this.queryManager.transform(this.options.query).hasForcedResolvers) {
3805
+ var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
3806
+ var shouldReturnCachedData = lastResult || (fetchPolicy !== 'network-only' &&
3807
+ fetchPolicy !== 'no-cache' &&
3808
+ fetchPolicy !== 'standby');
3809
+ if (shouldReturnCachedData &&
3810
+ !this.queryManager.transform(this.options.query).hasForcedResolvers) {
3812
3811
  var diff = this.queryInfo.getDiff();
3813
- result.data = (diff.complete ||
3814
- this.options.returnPartialData) ? diff.result : void 0;
3812
+ if (diff.complete || this.options.returnPartialData) {
3813
+ result.data = diff.result;
3814
+ }
3815
+ if (equality.equal(result.data, {})) {
3816
+ result.data = void 0;
3817
+ }
3815
3818
  if (diff.complete) {
3816
3819
  if (result.networkStatus === exports.NetworkStatus.loading &&
3817
3820
  (fetchPolicy === 'cache-first' ||
@@ -3839,24 +3842,31 @@ var ObservableQuery = (function (_super) {
3839
3842
  return result;
3840
3843
  };
3841
3844
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult) {
3842
- return !equality.equal(this.lastResultSnapshot, newResult);
3845
+ return !this.last || !equality.equal(this.last.result, newResult);
3843
3846
  };
3844
- ObservableQuery.prototype.getLastResult = function () {
3845
- return this.lastResult;
3847
+ ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
3848
+ var last = this.last;
3849
+ if (last &&
3850
+ last[key] &&
3851
+ (!variablesMustMatch || equality.equal(last.variables, this.variables))) {
3852
+ return last[key];
3853
+ }
3854
+ };
3855
+ ObservableQuery.prototype.getLastResult = function (variablesMustMatch) {
3856
+ return this.getLast("result", variablesMustMatch);
3846
3857
  };
3847
- ObservableQuery.prototype.getLastError = function () {
3848
- return this.lastError;
3858
+ ObservableQuery.prototype.getLastError = function (variablesMustMatch) {
3859
+ return this.getLast("error", variablesMustMatch);
3849
3860
  };
3850
3861
  ObservableQuery.prototype.resetLastResults = function () {
3851
- delete this.lastResult;
3852
- delete this.lastResultSnapshot;
3853
- delete this.lastError;
3862
+ delete this.last;
3854
3863
  this.isTornDown = false;
3855
3864
  };
3856
3865
  ObservableQuery.prototype.resetQueryStoreErrors = function () {
3857
3866
  this.queryManager.resetErrors(this.queryId);
3858
3867
  };
3859
3868
  ObservableQuery.prototype.refetch = function (variables) {
3869
+ var _a;
3860
3870
  var reobserveOptions = {
3861
3871
  pollInterval: 0,
3862
3872
  };
@@ -3867,6 +3877,13 @@ var ObservableQuery = (function (_super) {
3867
3877
  else if (fetchPolicy !== 'cache-and-network') {
3868
3878
  reobserveOptions.fetchPolicy = 'network-only';
3869
3879
  }
3880
+ if (__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
3881
+ var queryDef = getQueryDefinition(this.options.query);
3882
+ var vars = queryDef.variableDefinitions;
3883
+ if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
3884
+ __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 })?");
3885
+ }
3886
+ }
3870
3887
  if (variables && !equality.equal(this.options.variables, variables)) {
3871
3888
  reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
3872
3889
  }
@@ -3963,12 +3980,10 @@ var ObservableQuery = (function (_super) {
3963
3980
  }, exports.NetworkStatus.setVariables);
3964
3981
  };
3965
3982
  ObservableQuery.prototype.updateQuery = function (mapFn) {
3966
- var _a;
3967
3983
  var queryManager = this.queryManager;
3968
3984
  var result = queryManager.cache.diff({
3969
3985
  query: this.options.query,
3970
3986
  variables: this.variables,
3971
- previousResult: (_a = this.lastResult) === null || _a === void 0 ? void 0 : _a.data,
3972
3987
  returnPartialData: true,
3973
3988
  optimistic: false,
3974
3989
  }).result;
@@ -4013,7 +4028,7 @@ var ObservableQuery = (function (_super) {
4013
4028
  pollingInfo.interval === pollInterval) {
4014
4029
  return;
4015
4030
  }
4016
- __DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 13);
4031
+ __DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 12);
4017
4032
  var info = pollingInfo || (this.pollingInfo = {});
4018
4033
  info.interval = pollInterval;
4019
4034
  var maybeFetch = function () {
@@ -4037,18 +4052,18 @@ var ObservableQuery = (function (_super) {
4037
4052
  };
4038
4053
  poll();
4039
4054
  };
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);
4055
+ ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
4056
+ if (variables === void 0) { variables = this.variables; }
4057
+ this.last = tslib.__assign(tslib.__assign({}, this.last), { result: this.queryManager.assumeImmutableResults
4058
+ ? newResult
4059
+ : cloneDeep(newResult), variables: variables });
4046
4060
  if (!isNonEmptyArray(newResult.errors)) {
4047
- delete this.lastError;
4061
+ delete this.last.error;
4048
4062
  }
4049
- return previousResult;
4063
+ return this.last;
4050
4064
  };
4051
4065
  ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
4066
+ var _this = this;
4052
4067
  this.isTornDown = false;
4053
4068
  var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
4054
4069
  newNetworkStatus === exports.NetworkStatus.fetchMore ||
@@ -4056,7 +4071,7 @@ var ObservableQuery = (function (_super) {
4056
4071
  var oldVariables = this.options.variables;
4057
4072
  var options = useDisposableConcast
4058
4073
  ? compact(this.options, newOptions)
4059
- : Object.assign(this.options, compact(newOptions));
4074
+ : assign(this.options, compact(newOptions));
4060
4075
  if (!useDisposableConcast) {
4061
4076
  this.updatePolling();
4062
4077
  if (newOptions &&
@@ -4069,18 +4084,39 @@ var ObservableQuery = (function (_super) {
4069
4084
  }
4070
4085
  }
4071
4086
  }
4087
+ var variables = options.variables && tslib.__assign({}, options.variables);
4072
4088
  var concast = this.fetch(options, newNetworkStatus);
4089
+ var observer = {
4090
+ next: function (result) {
4091
+ _this.reportResult(result, variables);
4092
+ },
4093
+ error: function (error) {
4094
+ _this.reportError(error, variables);
4095
+ },
4096
+ };
4073
4097
  if (!useDisposableConcast) {
4074
- if (this.concast) {
4098
+ if (this.concast && this.observer) {
4075
4099
  this.concast.removeObserver(this.observer, true);
4076
4100
  }
4077
4101
  this.concast = concast;
4102
+ this.observer = observer;
4078
4103
  }
4079
- concast.addObserver(this.observer);
4104
+ concast.addObserver(observer);
4080
4105
  return concast.promise;
4081
4106
  };
4082
4107
  ObservableQuery.prototype.observe = function () {
4083
- this.observer.next(this.getCurrentResult(false));
4108
+ this.reportResult(this.getCurrentResult(false), this.variables);
4109
+ };
4110
+ ObservableQuery.prototype.reportResult = function (result, variables) {
4111
+ if (this.getLastError() || this.isDifferentFromLastResult(result)) {
4112
+ this.updateLastResult(result, variables);
4113
+ iterateObserversSafely(this.observers, 'next', result);
4114
+ }
4115
+ };
4116
+ ObservableQuery.prototype.reportError = function (error, variables) {
4117
+ var errorResult = tslib.__assign(tslib.__assign({}, this.getLastResult()), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false });
4118
+ this.updateLastResult(errorResult, variables);
4119
+ iterateObserversSafely(this.observers, 'error', this.last.error = error);
4084
4120
  };
4085
4121
  ObservableQuery.prototype.hasObservers = function () {
4086
4122
  return this.observers.size > 0;
@@ -4088,9 +4124,10 @@ var ObservableQuery = (function (_super) {
4088
4124
  ObservableQuery.prototype.tearDownQuery = function () {
4089
4125
  if (this.isTornDown)
4090
4126
  return;
4091
- if (this.concast) {
4127
+ if (this.concast && this.observer) {
4092
4128
  this.concast.removeObserver(this.observer);
4093
4129
  delete this.concast;
4130
+ delete this.observer;
4094
4131
  }
4095
4132
  this.stopPolling();
4096
4133
  this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
@@ -4288,7 +4325,7 @@ var LocalState = (function () {
4288
4325
  }
4289
4326
  else {
4290
4327
  fragment = fragmentMap[selection.name.value];
4291
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 12);
4328
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 11);
4292
4329
  }
4293
4330
  if (fragment && fragment.typeCondition) {
4294
4331
  typeCondition = fragment.typeCondition.name.value;
@@ -4674,7 +4711,7 @@ var QueryManager = (function () {
4674
4711
  this.queries.forEach(function (_info, queryId) {
4675
4712
  _this.stopQueryNoBroadcast(queryId);
4676
4713
  });
4677
- this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(14));
4714
+ this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(13));
4678
4715
  };
4679
4716
  QueryManager.prototype.cancelPendingFetches = function (error) {
4680
4717
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -4687,10 +4724,10 @@ var QueryManager = (function () {
4687
4724
  return tslib.__generator(this, function (_f) {
4688
4725
  switch (_f.label) {
4689
4726
  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);
4727
+ __DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 14);
4691
4728
  __DEV__ ? tsInvariant.invariant(fetchPolicy === 'network-only' ||
4692
4729
  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);
4730
+ fetchPolicy === 'no-cache', 15);
4694
4731
  mutationId = this.generateMutationId();
4695
4732
  mutation = this.transform(mutation).document;
4696
4733
  variables = this.getVariables(mutation, variables);
@@ -4975,10 +5012,10 @@ var QueryManager = (function () {
4975
5012
  var _this = this;
4976
5013
  if (queryId === void 0) { queryId = this.generateQueryId(); }
4977
5014
  __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);
5015
+ 'in the query option.') : tsInvariant.invariant(options.query, 16);
5016
+ __DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 17);
5017
+ __DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 18);
5018
+ __DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 19);
4982
5019
  return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
4983
5020
  };
4984
5021
  QueryManager.prototype.generateQueryId = function () {
@@ -5000,7 +5037,7 @@ var QueryManager = (function () {
5000
5037
  queryInfo.stop();
5001
5038
  };
5002
5039
  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));
5040
+ this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(20));
5004
5041
  this.queries.forEach(function (queryInfo) {
5005
5042
  if (queryInfo.observableQuery) {
5006
5043
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -5275,7 +5312,7 @@ var QueryManager = (function () {
5275
5312
  return _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
5276
5313
  };
5277
5314
  this.fetchCancelFns.set(queryId, function (reason) {
5278
- Promise.resolve().then(function () { return concast.cancel(reason); });
5315
+ setTimeout(function () { return concast.cancel(reason); });
5279
5316
  });
5280
5317
  var concast = new Concast(this.transform(normalized.query).hasClientExports
5281
5318
  ? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
@@ -5493,7 +5530,7 @@ var ApolloClient = (function () {
5493
5530
  if (!cache) {
5494
5531
  throw __DEV__ ? new tsInvariant.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
5495
5532
  "in the options object. \n" +
5496
- "For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(10);
5533
+ "For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(9);
5497
5534
  }
5498
5535
  this.link = link;
5499
5536
  this.cache = cache;
@@ -5589,7 +5626,7 @@ var ApolloClient = (function () {
5589
5626
  __DEV__ ? tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
5590
5627
  'client.query can only return a single result. Please use client.watchQuery ' +
5591
5628
  '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);
5629
+ 'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 10);
5593
5630
  if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
5594
5631
  options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
5595
5632
  }