@apollo/client 3.6.0-beta.2 → 3.6.0-beta.6

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 (144) hide show
  1. package/apollo-client.cjs +323 -274
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +36 -35
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/inmemory/helpers.d.ts +1 -0
  7. package/cache/inmemory/helpers.d.ts.map +1 -1
  8. package/cache/inmemory/helpers.js +4 -3
  9. package/cache/inmemory/helpers.js.map +1 -1
  10. package/cache/inmemory/key-extractor.js +7 -7
  11. package/cache/inmemory/key-extractor.js.map +1 -1
  12. package/cache/inmemory/object-canon.d.ts.map +1 -1
  13. package/cache/inmemory/object-canon.js +2 -1
  14. package/cache/inmemory/object-canon.js.map +1 -1
  15. package/cache/inmemory/policies.d.ts +1 -1
  16. package/cache/inmemory/policies.d.ts.map +1 -1
  17. package/cache/inmemory/policies.js +9 -9
  18. package/cache/inmemory/policies.js.map +1 -1
  19. package/cache/inmemory/readFromStore.js +6 -6
  20. package/cache/inmemory/readFromStore.js.map +1 -1
  21. package/cache/inmemory/writeToStore.js +13 -13
  22. package/cache/inmemory/writeToStore.js.map +1 -1
  23. package/core/ApolloClient.js +1 -1
  24. package/core/ApolloClient.js.map +1 -1
  25. package/core/LocalState.js +1 -1
  26. package/core/LocalState.js.map +1 -1
  27. package/core/ObservableQuery.d.ts.map +1 -1
  28. package/core/ObservableQuery.js +8 -5
  29. package/core/ObservableQuery.js.map +1 -1
  30. package/core/QueryManager.js +1 -1
  31. package/core/QueryManager.js.map +1 -1
  32. package/core/core.cjs +12 -9
  33. package/core/core.cjs.map +1 -1
  34. package/errors/errors.cjs +2 -2
  35. package/errors/errors.cjs.map +1 -1
  36. package/errors/index.js +2 -2
  37. package/errors/index.js.map +1 -1
  38. package/invariantErrorCodes.js +27 -27
  39. package/link/batch/batch.cjs +48 -38
  40. package/link/batch/batch.cjs.map +1 -1
  41. package/link/batch/batching.d.ts +2 -6
  42. package/link/batch/batching.d.ts.map +1 -1
  43. package/link/batch/batching.js +48 -38
  44. package/link/batch/batching.js.map +1 -1
  45. package/link/batch-http/batch-http.cjs +1 -1
  46. package/link/batch-http/batch-http.cjs.map +1 -1
  47. package/link/batch-http/batchHttpLink.js +2 -2
  48. package/link/batch-http/batchHttpLink.js.map +1 -1
  49. package/link/http/createHttpLink.js +2 -2
  50. package/link/http/createHttpLink.js.map +1 -1
  51. package/link/http/http.cjs +24 -13
  52. package/link/http/http.cjs.map +1 -1
  53. package/link/http/index.d.ts +1 -1
  54. package/link/http/index.d.ts.map +1 -1
  55. package/link/http/index.js +1 -1
  56. package/link/http/index.js.map +1 -1
  57. package/link/http/parseAndCheckHttpResponse.js +3 -3
  58. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  59. package/link/http/rewriteURIForGET.js +1 -1
  60. package/link/http/rewriteURIForGET.js.map +1 -1
  61. package/link/http/selectHttpOptionsAndBody.d.ts +5 -1
  62. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  63. package/link/http/selectHttpOptionsAndBody.js +19 -8
  64. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  65. package/link/http/serializeFetchParameter.js +1 -1
  66. package/link/http/serializeFetchParameter.js.map +1 -1
  67. package/link/subscriptions/index.d.ts +9 -0
  68. package/link/subscriptions/index.d.ts.map +1 -0
  69. package/link/subscriptions/index.js +39 -0
  70. package/link/subscriptions/index.js.map +1 -0
  71. package/link/subscriptions/package.json +8 -0
  72. package/link/subscriptions/subscriptions.cjs +45 -0
  73. package/link/subscriptions/subscriptions.cjs.map +1 -0
  74. package/link/utils/utils.cjs +1 -1
  75. package/link/utils/utils.cjs.map +1 -1
  76. package/link/utils/validateOperation.js +1 -1
  77. package/link/utils/validateOperation.js.map +1 -1
  78. package/package.json +22 -21
  79. package/react/hoc/hoc.cjs +5 -5
  80. package/react/hoc/hoc.cjs.map +1 -1
  81. package/react/hoc/mutation-hoc.js +2 -2
  82. package/react/hoc/mutation-hoc.js.map +1 -1
  83. package/react/hoc/query-hoc.js +1 -1
  84. package/react/hoc/query-hoc.js.map +1 -1
  85. package/react/hoc/subscription-hoc.js +1 -1
  86. package/react/hoc/subscription-hoc.js.map +1 -1
  87. package/react/hoc/withApollo.js +1 -1
  88. package/react/hoc/withApollo.js.map +1 -1
  89. package/react/hooks/hooks.cjs +225 -191
  90. package/react/hooks/hooks.cjs.map +1 -1
  91. package/react/hooks/useApolloClient.js +2 -2
  92. package/react/hooks/useApolloClient.js.map +1 -1
  93. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  94. package/react/hooks/useLazyQuery.js +20 -27
  95. package/react/hooks/useLazyQuery.js.map +1 -1
  96. package/react/hooks/useMutation.d.ts.map +1 -1
  97. package/react/hooks/useMutation.js +59 -68
  98. package/react/hooks/useMutation.js.map +1 -1
  99. package/react/hooks/useQuery.d.ts.map +1 -1
  100. package/react/hooks/useQuery.js +137 -88
  101. package/react/hooks/useQuery.js.map +1 -1
  102. package/react/hooks/useSubscription.d.ts.map +1 -1
  103. package/react/hooks/useSubscription.js +10 -8
  104. package/react/hooks/useSubscription.js.map +1 -1
  105. package/react/parser/index.js +7 -7
  106. package/react/parser/index.js.map +1 -1
  107. package/react/parser/parser.cjs +7 -7
  108. package/react/parser/parser.cjs.map +1 -1
  109. package/react/ssr/RenderPromises.d.ts +2 -2
  110. package/react/ssr/RenderPromises.d.ts.map +1 -1
  111. package/react/ssr/RenderPromises.js +7 -5
  112. package/react/ssr/RenderPromises.js.map +1 -1
  113. package/react/ssr/ssr.cjs +7 -5
  114. package/react/ssr/ssr.cjs.map +1 -1
  115. package/react/types/types.d.ts +1 -1
  116. package/react/types/types.d.ts.map +1 -1
  117. package/react/types/types.js.map +1 -1
  118. package/testing/core/core.cjs +2 -2
  119. package/testing/core/core.cjs.map +1 -1
  120. package/testing/core/mocking/mockFetch.js +1 -1
  121. package/testing/core/mocking/mockFetch.js.map +1 -1
  122. package/testing/core/mocking/mockLink.js +2 -2
  123. package/testing/core/mocking/mockLink.js.map +1 -1
  124. package/testing/core/observableToPromise.js +1 -1
  125. package/testing/core/observableToPromise.js.map +1 -1
  126. package/utilities/common/makeUniqueId.js +1 -1
  127. package/utilities/common/makeUniqueId.js.map +1 -1
  128. package/utilities/globals/global.d.ts +2 -8
  129. package/utilities/globals/global.d.ts.map +1 -1
  130. package/utilities/globals/global.js +1 -1
  131. package/utilities/globals/global.js.map +1 -1
  132. package/utilities/globals/globals.cjs +1 -1
  133. package/utilities/globals/globals.cjs.map +1 -1
  134. package/utilities/graphql/directives.js +4 -4
  135. package/utilities/graphql/directives.js.map +1 -1
  136. package/utilities/graphql/fragments.js +3 -3
  137. package/utilities/graphql/fragments.js.map +1 -1
  138. package/utilities/graphql/getFromAST.js +2 -2
  139. package/utilities/graphql/getFromAST.js.map +1 -1
  140. package/utilities/graphql/storeUtils.js +5 -5
  141. package/utilities/graphql/storeUtils.js.map +1 -1
  142. package/utilities/utilities.cjs +15 -15
  143. package/utilities/utilities.cjs.map +1 -1
  144. package/version.js +1 -1
package/core/core.cjs CHANGED
@@ -15,7 +15,7 @@ var utils = require('../link/utils');
15
15
  var tsInvariant = require('ts-invariant');
16
16
  var graphqlTag = require('graphql-tag');
17
17
 
18
- var version = '3.6.0-beta.2';
18
+ var version = '3.6.0-beta.6';
19
19
 
20
20
  exports.NetworkStatus = void 0;
21
21
  (function (NetworkStatus) {
@@ -178,7 +178,7 @@ var ObservableQuery = (function (_super) {
178
178
  pollInterval: 0,
179
179
  };
180
180
  var fetchPolicy = this.options.fetchPolicy;
181
- if (fetchPolicy === 'standby' || fetchPolicy === 'cache-and-network') {
181
+ if (fetchPolicy === 'cache-and-network') {
182
182
  reobserveOptions.fetchPolicy = fetchPolicy;
183
183
  }
184
184
  else if (fetchPolicy === 'no-cache') {
@@ -191,7 +191,7 @@ var ObservableQuery = (function (_super) {
191
191
  var queryDef = utilities.getQueryDefinition(this.options.query);
192
192
  var vars = queryDef.variableDefinitions;
193
193
  if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
194
- __DEV__ && globals.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 })?");
194
+ __DEV__ && globals.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_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 })?"));
195
195
  }
196
196
  }
197
197
  if (variables && !equality.equal(this.options.variables, variables)) {
@@ -418,8 +418,11 @@ var ObservableQuery = (function (_super) {
418
418
  this.reportResult(this.getCurrentResult(false), this.variables);
419
419
  };
420
420
  ObservableQuery.prototype.reportResult = function (result, variables) {
421
- if (this.getLastError() || this.isDifferentFromLastResult(result)) {
422
- this.updateLastResult(result, variables);
421
+ var lastError = this.getLastError();
422
+ if (lastError || this.isDifferentFromLastResult(result)) {
423
+ if (lastError || !result.partial || this.options.returnPartialData) {
424
+ this.updateLastResult(result, variables);
425
+ }
423
426
  utilities.iterateObserversSafely(this.observers, 'next', result);
424
427
  }
425
428
  };
@@ -454,7 +457,7 @@ function defaultSubscriptionObserverErrorCallback(error) {
454
457
  }
455
458
  function logMissingFieldErrors(missing) {
456
459
  if (__DEV__ && missing) {
457
- __DEV__ && globals.invariant.debug("Missing cache result fields: " + JSON.stringify(missing), missing);
460
+ __DEV__ && globals.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
458
461
  }
459
462
  }
460
463
  function applyNextFetchPolicy(options) {
@@ -635,7 +638,7 @@ var LocalState = (function () {
635
638
  }
636
639
  else {
637
640
  fragment = fragmentMap[selection.name.value];
638
- __DEV__ ? globals.invariant(fragment, "No fragment named " + selection.name.value) : globals.invariant(fragment, 9);
641
+ __DEV__ ? globals.invariant(fragment, "No fragment named ".concat(selection.name.value)) : globals.invariant(fragment, 9);
639
642
  }
640
643
  if (fragment && fragment.typeCondition) {
641
644
  typeCondition = fragment.typeCondition.name.value;
@@ -1426,7 +1429,7 @@ var QueryManager = (function () {
1426
1429
  if (__DEV__ && queryNamesAndDocs.size) {
1427
1430
  queryNamesAndDocs.forEach(function (included, nameOrDoc) {
1428
1431
  if (!included) {
1429
- __DEV__ && globals.invariant.warn("Unknown query " + (typeof nameOrDoc === "string" ? "named " : "") + JSON.stringify(nameOrDoc, null, 2) + " requested in refetchQueries options.include array");
1432
+ __DEV__ && globals.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
1430
1433
  }
1431
1434
  });
1432
1435
  }
@@ -2017,7 +2020,7 @@ var ApolloClient = (function () {
2017
2020
  result.queries = queries;
2018
2021
  result.results = results;
2019
2022
  result.catch(function (error) {
2020
- __DEV__ && globals.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error " + error);
2023
+ __DEV__ && globals.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
2021
2024
  });
2022
2025
  return result;
2023
2026
  };