@apollo/client 3.8.4 → 3.8.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 (141) hide show
  1. package/apollo-client.cjs +168 -149
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +46 -11
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +46 -11
  7. package/cache/core/types/common.d.ts +2 -2
  8. package/cache/core/types/common.d.ts.map +1 -1
  9. package/cache/core/types/common.js.map +1 -1
  10. package/cache/inmemory/entityStore.d.ts.map +1 -1
  11. package/cache/inmemory/entityStore.js +35 -0
  12. package/cache/inmemory/entityStore.js.map +1 -1
  13. package/cache/inmemory/key-extractor.js +1 -1
  14. package/cache/inmemory/policies.js +4 -4
  15. package/cache/inmemory/readFromStore.js +2 -2
  16. package/cache/inmemory/writeToStore.js +4 -4
  17. package/core/ApolloClient.js +3 -3
  18. package/core/LocalState.js +2 -2
  19. package/core/ObservableQuery.d.ts.map +1 -1
  20. package/core/ObservableQuery.js +10 -11
  21. package/core/ObservableQuery.js.map +1 -1
  22. package/core/QueryInfo.d.ts +0 -2
  23. package/core/QueryInfo.d.ts.map +1 -1
  24. package/core/QueryInfo.js +0 -2
  25. package/core/QueryInfo.js.map +1 -1
  26. package/core/QueryManager.js +11 -11
  27. package/core/QueryManager.js.map +1 -1
  28. package/core/core.cjs +27 -30
  29. package/core/core.cjs.map +1 -1
  30. package/core/core.cjs.native.js +27 -30
  31. package/dev/dev.cjs +124 -100
  32. package/dev/dev.cjs.map +1 -1
  33. package/dev/dev.cjs.native.js +124 -100
  34. package/dev/loadErrorMessageHandler.js +2 -2
  35. package/dev/loadErrorMessageHandler.js.map +1 -1
  36. package/invariantErrorCodes.js +95 -80
  37. package/link/core/ApolloLink.js +2 -2
  38. package/link/core/core.cjs +2 -2
  39. package/link/core/core.cjs.map +1 -1
  40. package/link/core/core.cjs.native.js +2 -2
  41. package/link/http/checkFetcher.js +1 -1
  42. package/link/http/createHttpLink.js +1 -1
  43. package/link/http/http.cjs +3 -3
  44. package/link/http/http.cjs.map +1 -1
  45. package/link/http/http.cjs.native.js +3 -3
  46. package/link/http/serializeFetchParameter.js +1 -1
  47. package/link/persisted-queries/index.js +2 -2
  48. package/link/persisted-queries/persisted-queries.cjs +2 -2
  49. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  50. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  51. package/link/utils/toPromise.js +1 -1
  52. package/link/utils/utils.cjs +2 -2
  53. package/link/utils/utils.cjs.map +1 -1
  54. package/link/utils/utils.cjs.native.js +2 -2
  55. package/link/utils/validateOperation.js +1 -1
  56. package/package.json +22 -22
  57. package/react/cache/QueryReference.d.ts.map +1 -1
  58. package/react/cache/QueryReference.js +7 -2
  59. package/react/cache/QueryReference.js.map +1 -1
  60. package/react/cache/index.d.ts +0 -4
  61. package/react/cache/index.d.ts.map +1 -1
  62. package/react/cache/index.js +0 -14
  63. package/react/cache/index.js.map +1 -1
  64. package/react/context/ApolloConsumer.js +1 -1
  65. package/react/context/ApolloContext.js +1 -1
  66. package/react/context/ApolloProvider.js +1 -1
  67. package/react/context/context.cjs +3 -3
  68. package/react/context/context.cjs.map +1 -1
  69. package/react/context/context.cjs.native.js +3 -3
  70. package/react/hoc/hoc-utils.js +1 -1
  71. package/react/hoc/hoc.cjs +2 -2
  72. package/react/hoc/hoc.cjs.map +1 -1
  73. package/react/hoc/hoc.cjs.native.js +2 -2
  74. package/react/hoc/withApollo.js +1 -1
  75. package/react/hooks/hooks.cjs +15 -10
  76. package/react/hooks/hooks.cjs.map +1 -1
  77. package/react/hooks/hooks.cjs.native.js +15 -10
  78. package/react/hooks/useApolloClient.js +1 -1
  79. package/react/hooks/useQuery.js +1 -1
  80. package/react/hooks/useReadQuery.js +1 -1
  81. package/react/hooks/useSubscription.js +2 -2
  82. package/react/hooks/useSuspenseQuery.js +2 -2
  83. package/react/hooks/useSyncExternalStore.js +1 -1
  84. package/react/index.d.ts +0 -1
  85. package/react/index.d.ts.map +1 -1
  86. package/react/index.js +0 -1
  87. package/react/index.js.map +1 -1
  88. package/react/parser/index.js +5 -5
  89. package/react/parser/parser.cjs +5 -5
  90. package/react/parser/parser.cjs.map +1 -1
  91. package/react/parser/parser.cjs.native.js +5 -5
  92. package/react/react.cjs +1 -218
  93. package/react/react.cjs.map +1 -1
  94. package/react/react.cjs.native.js +1 -218
  95. package/react/types/types.d.ts +0 -3
  96. package/react/types/types.d.ts.map +1 -1
  97. package/react/types/types.js.map +1 -1
  98. package/testing/core/core.cjs +1 -1
  99. package/testing/core/core.cjs.map +1 -1
  100. package/testing/core/core.cjs.native.js +1 -1
  101. package/testing/core/mocking/mockLink.js +1 -1
  102. package/testing/internal/ObservableStream.d.ts +26 -0
  103. package/testing/internal/ObservableStream.d.ts.map +1 -0
  104. package/testing/internal/ObservableStream.js +101 -0
  105. package/testing/internal/ObservableStream.js.map +1 -0
  106. package/testing/internal/index.d.ts +1 -0
  107. package/testing/internal/index.d.ts.map +1 -1
  108. package/testing/internal/index.js +1 -0
  109. package/testing/internal/index.js.map +1 -1
  110. package/testing/react/MockedProvider.d.ts +1 -0
  111. package/testing/react/MockedProvider.d.ts.map +1 -1
  112. package/testing/react/MockedProvider.js +2 -1
  113. package/testing/react/MockedProvider.js.map +1 -1
  114. package/testing/testing.cjs +2 -1
  115. package/testing/testing.cjs.map +1 -1
  116. package/testing/testing.cjs.native.js +2 -1
  117. package/utilities/globals/globals.cjs +29 -19
  118. package/utilities/globals/globals.cjs.map +1 -1
  119. package/utilities/globals/globals.cjs.native.js +29 -19
  120. package/utilities/globals/invariantWrappers.d.ts.map +1 -1
  121. package/utilities/globals/invariantWrappers.js +28 -18
  122. package/utilities/globals/invariantWrappers.js.map +1 -1
  123. package/utilities/graphql/DocumentTransform.js +1 -1
  124. package/utilities/graphql/directives.js +4 -4
  125. package/utilities/graphql/fragments.js +3 -3
  126. package/utilities/graphql/getFromAST.js +8 -8
  127. package/utilities/graphql/storeUtils.d.ts +5 -0
  128. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  129. package/utilities/graphql/storeUtils.js +1 -1
  130. package/utilities/graphql/storeUtils.js.map +1 -1
  131. package/utilities/graphql/transform.js +2 -2
  132. package/utilities/index.d.ts +1 -1
  133. package/utilities/index.d.ts.map +1 -1
  134. package/utilities/index.js.map +1 -1
  135. package/utilities/observables/asyncMap.d.ts.map +1 -1
  136. package/utilities/observables/asyncMap.js +17 -34
  137. package/utilities/observables/asyncMap.js.map +1 -1
  138. package/utilities/utilities.cjs +36 -53
  139. package/utilities/utilities.cjs.map +1 -1
  140. package/utilities/utilities.cjs.native.js +36 -53
  141. package/version.js +1 -1
@@ -20,7 +20,7 @@ function shouldInclude(_a, variables) {
20
20
  if (ifArgument.value.kind === "Variable") {
21
21
  evaledValue =
22
22
  variables && variables[ifArgument.value.name.value];
23
- globals.invariant(evaledValue !== void 0, 64, directive.name.value);
23
+ globals.invariant(evaledValue !== void 0, 66, directive.name.value);
24
24
  }
25
25
  else {
26
26
  evaledValue = ifArgument.value.value;
@@ -70,12 +70,12 @@ function getInclusionDirectives(directives) {
70
70
  return;
71
71
  var directiveArguments = directive.arguments;
72
72
  var directiveName = directive.name.value;
73
- globals.invariant(directiveArguments && directiveArguments.length === 1, 65, directiveName);
73
+ globals.invariant(directiveArguments && directiveArguments.length === 1, 67, directiveName);
74
74
  var ifArgument = directiveArguments[0];
75
- globals.invariant(ifArgument.name && ifArgument.name.value === "if", 66, directiveName);
75
+ globals.invariant(ifArgument.name && ifArgument.name.value === "if", 68, directiveName);
76
76
  var ifValue = ifArgument.value;
77
77
  globals.invariant(ifValue &&
78
- (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 67, directiveName);
78
+ (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 69, directiveName);
79
79
  result.push({ directive: directive, ifArgument: ifArgument });
80
80
  });
81
81
  }
@@ -107,7 +107,7 @@ function getFragmentQueryDocument(document, fragmentName) {
107
107
  document.definitions.forEach(function (definition) {
108
108
  if (definition.kind === "OperationDefinition") {
109
109
  throw globals.newInvariantError(
110
- 68,
110
+ 70,
111
111
  definition.operation,
112
112
  definition.name ? " named '".concat(definition.name.value, "'") : ""
113
113
  );
@@ -117,7 +117,7 @@ function getFragmentQueryDocument(document, fragmentName) {
117
117
  }
118
118
  });
119
119
  if (typeof actualFragmentName === "undefined") {
120
- globals.invariant(fragments.length === 1, 69, fragments.length);
120
+ globals.invariant(fragments.length === 1, 71, fragments.length);
121
121
  actualFragmentName = fragments[0].name.value;
122
122
  }
123
123
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -158,7 +158,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
158
158
  return fragmentMap(fragmentName);
159
159
  }
160
160
  var fragment = fragmentMap && fragmentMap[fragmentName];
161
- globals.invariant(fragment, 70, fragmentName);
161
+ globals.invariant(fragment, 72, fragmentName);
162
162
  return fragment || null;
163
163
  }
164
164
  default:
@@ -236,7 +236,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
236
236
  argObj[name.value] = null;
237
237
  }
238
238
  else {
239
- throw globals.newInvariantError(79, name.value, value.kind);
239
+ throw globals.newInvariantError(81, name.value, value.kind);
240
240
  }
241
241
  }
242
242
  function storeKeyNameFromField(field, variables) {
@@ -383,16 +383,16 @@ function isInlineFragment(selection) {
383
383
  }
384
384
 
385
385
  function checkDocument(doc) {
386
- globals.invariant(doc && doc.kind === "Document", 71);
386
+ globals.invariant(doc && doc.kind === "Document", 73);
387
387
  var operations = doc.definitions
388
388
  .filter(function (d) { return d.kind !== "FragmentDefinition"; })
389
389
  .map(function (definition) {
390
390
  if (definition.kind !== "OperationDefinition") {
391
- throw globals.newInvariantError(72, definition.kind);
391
+ throw globals.newInvariantError(74, definition.kind);
392
392
  }
393
393
  return definition;
394
394
  });
395
- globals.invariant(operations.length <= 1, 73, operations.length);
395
+ globals.invariant(operations.length <= 1, 75, operations.length);
396
396
  return doc;
397
397
  }
398
398
  function getOperationDefinition(doc) {
@@ -415,14 +415,14 @@ function getFragmentDefinitions(doc) {
415
415
  }
416
416
  function getQueryDefinition(doc) {
417
417
  var queryDef = getOperationDefinition(doc);
418
- globals.invariant(queryDef && queryDef.operation === "query", 74);
418
+ globals.invariant(queryDef && queryDef.operation === "query", 76);
419
419
  return queryDef;
420
420
  }
421
421
  function getFragmentDefinition(doc) {
422
- globals.invariant(doc.kind === "Document", 75);
423
- globals.invariant(doc.definitions.length <= 1, 76);
422
+ globals.invariant(doc.kind === "Document", 77);
423
+ globals.invariant(doc.definitions.length <= 1, 78);
424
424
  var fragmentDef = doc.definitions[0];
425
- globals.invariant(fragmentDef.kind === "FragmentDefinition", 77);
425
+ globals.invariant(fragmentDef.kind === "FragmentDefinition", 79);
426
426
  return fragmentDef;
427
427
  }
428
428
  function getMainDefinition(queryDoc) {
@@ -445,7 +445,7 @@ function getMainDefinition(queryDoc) {
445
445
  if (fragmentDefinition) {
446
446
  return fragmentDefinition;
447
447
  }
448
- throw globals.newInvariantError(78);
448
+ throw globals.newInvariantError(80);
449
449
  }
450
450
  function getDefaultValues(definition) {
451
451
  var defaultValues = Object.create(null);
@@ -517,7 +517,7 @@ var DocumentTransform = (function () {
517
517
  return;
518
518
  var cacheKeys = this.getCacheKey(document);
519
519
  if (cacheKeys) {
520
- globals.invariant(Array.isArray(cacheKeys), 63);
520
+ globals.invariant(Array.isArray(cacheKeys), 65);
521
521
  return this.stableCacheKeys.lookupArray(cacheKeys);
522
522
  }
523
523
  };
@@ -613,7 +613,7 @@ function removeDirectivesFromDocument(directives, doc) {
613
613
  return getInUseByFragmentName(ancestor.name.value);
614
614
  }
615
615
  }
616
- globalThis.__DEV__ !== false && globals.invariant.error(80);
616
+ globalThis.__DEV__ !== false && globals.invariant.error(82);
617
617
  return null;
618
618
  };
619
619
  var operationCount = 0;
@@ -800,7 +800,7 @@ var connectionRemoveConfig = {
800
800
  if (willRemove) {
801
801
  if (!directive.arguments ||
802
802
  !directive.arguments.some(function (arg) { return arg.name.value === "key"; })) {
803
- globalThis.__DEV__ !== false && globals.invariant.warn(81);
803
+ globalThis.__DEV__ !== false && globals.invariant.warn(83);
804
804
  }
805
805
  }
806
806
  return willRemove;
@@ -1249,48 +1249,31 @@ function iterateObserversSafely(observers, method, argument) {
1249
1249
 
1250
1250
  function asyncMap(observable, mapFn, catchFn) {
1251
1251
  return new zenObservableTs.Observable(function (observer) {
1252
- var next = observer.next, error = observer.error, complete = observer.complete;
1253
- var activeCallbackCount = 0;
1254
- var completed = false;
1255
1252
  var promiseQueue = {
1256
1253
  then: function (callback) {
1257
1254
  return new Promise(function (resolve) { return resolve(callback()); });
1258
1255
  },
1259
1256
  };
1260
- function makeCallback(examiner, delegate) {
1261
- if (examiner) {
1262
- return function (arg) {
1263
- ++activeCallbackCount;
1264
- var both = function () { return examiner(arg); };
1265
- promiseQueue = promiseQueue
1266
- .then(both, both)
1267
- .then(function (result) {
1268
- --activeCallbackCount;
1269
- next && next.call(observer, result);
1270
- if (completed) {
1271
- handler.complete();
1272
- }
1273
- }, function (error) {
1274
- --activeCallbackCount;
1275
- throw error;
1276
- })
1277
- .catch(function (caught) {
1278
- error && error.call(observer, caught);
1279
- });
1280
- };
1281
- }
1282
- else {
1283
- return function (arg) { return delegate && delegate.call(observer, arg); };
1284
- }
1257
+ function makeCallback(examiner, key) {
1258
+ return function (arg) {
1259
+ if (examiner) {
1260
+ var both = function () {
1261
+ return observer.closed
1262
+ ? 0
1263
+ : examiner(arg);
1264
+ };
1265
+ promiseQueue = promiseQueue.then(both, both).then(function (result) { return observer.next(result); }, function (error) { return observer.error(error); });
1266
+ }
1267
+ else {
1268
+ observer[key](arg);
1269
+ }
1270
+ };
1285
1271
  }
1286
1272
  var handler = {
1287
- next: makeCallback(mapFn, next),
1288
- error: makeCallback(catchFn, error),
1273
+ next: makeCallback(mapFn, "next"),
1274
+ error: makeCallback(catchFn, "error"),
1289
1275
  complete: function () {
1290
- completed = true;
1291
- if (!activeCallbackCount) {
1292
- complete && complete.call(observer);
1293
- }
1276
+ promiseQueue.then(function () { return observer.complete(); });
1294
1277
  },
1295
1278
  };
1296
1279
  var sub = observable.subscribe(handler);
package/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export var version = "3.8.4";
1
+ export var version = "3.8.6";
2
2
  //# sourceMappingURL=version.js.map