@apollo/client 3.8.0-beta.2 → 3.8.0-beta.3

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 (111) hide show
  1. package/apollo-client.cjs +32 -19
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs.map +1 -1
  5. package/cache/core/cache.d.ts +1 -1
  6. package/cache/core/cache.d.ts.map +1 -1
  7. package/cache/core/cache.js.map +1 -1
  8. package/cache/core/types/Cache.d.ts +3 -3
  9. package/cache/core/types/Cache.d.ts.map +1 -1
  10. package/cache/core/types/Cache.js +1 -0
  11. package/cache/core/types/Cache.js.map +1 -1
  12. package/cache/core/types/common.d.ts +17 -6
  13. package/cache/core/types/common.d.ts.map +1 -1
  14. package/cache/core/types/common.js.map +1 -1
  15. package/cache/inmemory/entityStore.d.ts +1 -1
  16. package/cache/inmemory/entityStore.d.ts.map +1 -1
  17. package/cache/inmemory/entityStore.js.map +1 -1
  18. package/cache/inmemory/inMemoryCache.d.ts +1 -1
  19. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  20. package/cache/inmemory/inMemoryCache.js.map +1 -1
  21. package/cache/inmemory/types.d.ts +2 -2
  22. package/cache/inmemory/types.d.ts.map +1 -1
  23. package/cache/inmemory/types.js.map +1 -1
  24. package/core/QueryManager.d.ts.map +1 -1
  25. package/core/QueryManager.js +5 -3
  26. package/core/QueryManager.js.map +1 -1
  27. package/core/core.cjs +5 -4
  28. package/core/core.cjs.map +1 -1
  29. package/core/core.cjs.native.js +5 -4
  30. package/dev/dev.cjs +1 -1
  31. package/dev/dev.cjs.map +1 -1
  32. package/dev/dev.cjs.native.js +1 -1
  33. package/link/batch-http/batch-http.cjs +5 -4
  34. package/link/batch-http/batch-http.cjs.map +1 -1
  35. package/link/batch-http/batch-http.cjs.native.js +5 -4
  36. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  37. package/link/batch-http/batchHttpLink.js +1 -1
  38. package/link/batch-http/batchHttpLink.js.map +1 -1
  39. package/link/http/createHttpLink.js +1 -1
  40. package/link/http/createHttpLink.js.map +1 -1
  41. package/link/http/http.cjs +2 -3
  42. package/link/http/http.cjs.map +1 -1
  43. package/link/http/http.cjs.native.js +2 -3
  44. package/link/http/selectHttpOptionsAndBody.d.ts +1 -1
  45. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  46. package/link/http/selectHttpOptionsAndBody.js +1 -1
  47. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  48. package/link/persisted-queries/index.js +1 -1
  49. package/link/persisted-queries/index.js.map +1 -1
  50. package/link/persisted-queries/persisted-queries.cjs +2 -3
  51. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  52. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -3
  53. package/link/subscriptions/index.js +1 -1
  54. package/link/subscriptions/index.js.map +1 -1
  55. package/link/subscriptions/subscriptions.cjs +2 -3
  56. package/link/subscriptions/subscriptions.cjs.map +1 -1
  57. package/link/subscriptions/subscriptions.cjs.native.js +2 -3
  58. package/link/utils/filterOperationVariables.d.ts +2 -2
  59. package/link/utils/filterOperationVariables.d.ts.map +1 -1
  60. package/link/utils/filterOperationVariables.js +5 -4
  61. package/link/utils/filterOperationVariables.js.map +1 -1
  62. package/link/utils/utils.cjs +4 -3
  63. package/link/utils/utils.cjs.map +1 -1
  64. package/link/utils/utils.cjs.native.js +4 -3
  65. package/package.json +1 -1
  66. package/react/cache/SuspenseCache.d.ts +0 -1
  67. package/react/cache/SuspenseCache.d.ts.map +1 -1
  68. package/react/cache/SuspenseCache.js +10 -10
  69. package/react/cache/SuspenseCache.js.map +1 -1
  70. package/react/hooks/useBackgroundQuery.d.ts +14 -5
  71. package/react/hooks/useBackgroundQuery.d.ts.map +1 -1
  72. package/react/hooks/useBackgroundQuery.js.map +1 -1
  73. package/react/hooks/useSuspenseQuery.d.ts +0 -1
  74. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  75. package/react/hooks/useSuspenseQuery.js.map +1 -1
  76. package/react/react.cjs +10 -10
  77. package/react/react.cjs.map +1 -1
  78. package/react/react.cjs.native.js +10 -10
  79. package/react/types/types.d.ts +1 -0
  80. package/react/types/types.d.ts.map +1 -1
  81. package/react/types/types.js.map +1 -1
  82. package/testing/core/core.cjs +2 -3
  83. package/testing/core/core.cjs.map +1 -1
  84. package/testing/core/core.cjs.native.js +2 -3
  85. package/testing/core/mocking/mockLink.d.ts.map +1 -1
  86. package/testing/core/mocking/mockLink.js +1 -2
  87. package/testing/core/mocking/mockLink.js.map +1 -1
  88. package/testing/matchers/index.js +2 -0
  89. package/testing/matchers/index.js.map +1 -1
  90. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts +12 -0
  91. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +1 -0
  92. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +18 -0
  93. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -0
  94. package/testing/matchers/toMatchDocument.d.ts.map +1 -1
  95. package/testing/matchers/toMatchDocument.js +1 -2
  96. package/testing/matchers/toMatchDocument.js.map +1 -1
  97. package/utilities/globals/globals.cjs +1 -1
  98. package/utilities/globals/globals.cjs.map +1 -1
  99. package/utilities/globals/globals.cjs.native.js +1 -1
  100. package/utilities/graphql/print.d.ts +3 -0
  101. package/utilities/graphql/print.d.ts.map +1 -0
  102. package/utilities/graphql/print.js +13 -0
  103. package/utilities/graphql/print.js.map +1 -0
  104. package/utilities/index.d.ts +1 -0
  105. package/utilities/index.d.ts.map +1 -1
  106. package/utilities/index.js +1 -0
  107. package/utilities/index.js.map +1 -1
  108. package/utilities/utilities.cjs +12 -0
  109. package/utilities/utilities.cjs.map +1 -1
  110. package/utilities/utilities.cjs.native.js +12 -0
  111. package/version.js +1 -1
package/apollo-client.cjs CHANGED
@@ -33,7 +33,7 @@ var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
33
33
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
34
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
35
35
 
36
- var version = '3.8.0-beta.2';
36
+ var version = '3.8.0-beta.3';
37
37
 
38
38
  function maybe(thunk) {
39
39
  try {
@@ -614,6 +614,17 @@ var DocumentTransform = (function () {
614
614
  return DocumentTransform;
615
615
  }());
616
616
 
617
+ var printCache = canUseWeakMap ? new WeakMap() : undefined;
618
+ var print = function (ast) {
619
+ var result;
620
+ result = printCache === null || printCache === void 0 ? void 0 : printCache.get(ast);
621
+ if (!result) {
622
+ result = graphql.print(ast);
623
+ printCache === null || printCache === void 0 ? void 0 : printCache.set(ast, result);
624
+ }
625
+ return result;
626
+ };
627
+
617
628
  var isArray = Array.isArray;
618
629
  function isNonEmptyArray(value) {
619
630
  return Array.isArray(value) && value.length > 0;
@@ -1453,12 +1464,13 @@ function transformOperation(operation) {
1453
1464
  return transformedOperation;
1454
1465
  }
1455
1466
 
1456
- function filterOperationVariables(variables, operation) {
1467
+ function filterOperationVariables(variables, query) {
1457
1468
  var result = tslib.__assign({}, variables);
1458
1469
  var unusedNames = new Set(Object.keys(variables));
1459
- graphql.visit(operation.query, {
1470
+ graphql.visit(query, {
1460
1471
  Variable: function (node, _key, parent) {
1461
- if (parent && parent.kind !== 'VariableDefinition') {
1472
+ if (parent &&
1473
+ parent.kind !== 'VariableDefinition') {
1462
1474
  unusedNames.delete(node.name.value);
1463
1475
  }
1464
1476
  },
@@ -1970,7 +1982,7 @@ function selectHttpOptionsAndBodyInternal(operation, printer) {
1970
1982
  if (http.includeExtensions)
1971
1983
  body.extensions = extensions;
1972
1984
  if (http.includeQuery)
1973
- body.query = printer(query, graphql.print);
1985
+ body.query = printer(query, print);
1974
1986
  return {
1975
1987
  options: options,
1976
1988
  body: body,
@@ -2107,7 +2119,7 @@ var createHttpLink = function (linkOptions) {
2107
2119
  }
2108
2120
  var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
2109
2121
  if (body.variables && !includeUnusedVariables) {
2110
- body.variables = filterOperationVariables(body.variables, operation);
2122
+ body.variables = filterOperationVariables(body.variables, operation.query);
2111
2123
  }
2112
2124
  var controller;
2113
2125
  if (!options.signal) {
@@ -6263,8 +6275,9 @@ var QueryManager = (function () {
6263
6275
  };
6264
6276
  context = operation.context;
6265
6277
  if (deduplication) {
6266
- var byVariables_1 = inFlightLinkObservables_1.get(serverQuery) || new Map();
6267
- inFlightLinkObservables_1.set(serverQuery, byVariables_1);
6278
+ var printedServerQuery_1 = print(serverQuery);
6279
+ var byVariables_1 = inFlightLinkObservables_1.get(printedServerQuery_1) || new Map();
6280
+ inFlightLinkObservables_1.set(printedServerQuery_1, byVariables_1);
6268
6281
  var varJson_1 = canonicalStringify(variables);
6269
6282
  observable = byVariables_1.get(varJson_1);
6270
6283
  if (!observable) {
@@ -6275,7 +6288,7 @@ var QueryManager = (function () {
6275
6288
  concast.beforeNext(function () {
6276
6289
  if (byVariables_1.delete(varJson_1) &&
6277
6290
  byVariables_1.size < 1) {
6278
- inFlightLinkObservables_1.delete(serverQuery);
6291
+ inFlightLinkObservables_1.delete(printedServerQuery_1);
6279
6292
  }
6280
6293
  });
6281
6294
  }
@@ -7913,21 +7926,21 @@ var QueryReference = (function () {
7913
7926
  var SuspenseCache = (function () {
7914
7927
  function SuspenseCache(options) {
7915
7928
  if (options === void 0) { options = Object.create(null); }
7916
- this.cacheKeys = new trie.Trie(canUseWeakMap, function (cacheKey) { return cacheKey; });
7917
- this.queryRefs = new Map();
7929
+ this.queryRefs = new trie.Trie(canUseWeakMap);
7918
7930
  this.options = options;
7919
7931
  }
7920
7932
  SuspenseCache.prototype.getQueryRef = function (cacheKey, createObservable) {
7921
- var _this = this;
7922
- var stableCacheKey = this.cacheKeys.lookupArray(cacheKey);
7923
- if (!this.queryRefs.has(stableCacheKey)) {
7924
- this.queryRefs.set(stableCacheKey, new QueryReference(createObservable(), {
7925
- key: stableCacheKey,
7933
+ var ref = this.queryRefs.lookupArray(cacheKey);
7934
+ if (!ref.current) {
7935
+ ref.current = new QueryReference(createObservable(), {
7936
+ key: cacheKey,
7926
7937
  autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
7927
- onDispose: function () { return _this.queryRefs.delete(stableCacheKey); },
7928
- }));
7938
+ onDispose: function () {
7939
+ delete ref.current;
7940
+ },
7941
+ });
7929
7942
  }
7930
- return this.queryRefs.get(stableCacheKey);
7943
+ return ref.current;
7931
7944
  };
7932
7945
  return SuspenseCache;
7933
7946
  }());