@apollo/client 3.8.0-alpha.11 → 3.8.0-alpha.12

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 (152) hide show
  1. package/apollo-client.cjs +452 -281
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/core/ApolloClient.d.ts.map +1 -1
  5. package/core/ApolloClient.js.map +1 -1
  6. package/core/ObservableQuery.d.ts +2 -1
  7. package/core/ObservableQuery.d.ts.map +1 -1
  8. package/core/ObservableQuery.js +30 -19
  9. package/core/ObservableQuery.js.map +1 -1
  10. package/core/QueryManager.d.ts +2 -0
  11. package/core/QueryManager.d.ts.map +1 -1
  12. package/core/QueryManager.js +60 -48
  13. package/core/QueryManager.js.map +1 -1
  14. package/core/core.cjs +175 -82
  15. package/core/core.cjs.map +1 -1
  16. package/core/core.cjs.native.js +175 -82
  17. package/core/equalByQuery.d.ts +4 -0
  18. package/core/equalByQuery.d.ts.map +1 -0
  19. package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
  20. package/core/equalByQuery.js.map +1 -0
  21. package/core/index.d.ts +1 -1
  22. package/core/index.d.ts.map +1 -1
  23. package/core/index.js +1 -1
  24. package/core/index.js.map +1 -1
  25. package/errors/errors.cjs +17 -17
  26. package/errors/errors.cjs.map +1 -1
  27. package/errors/errors.cjs.native.js +17 -17
  28. package/errors/index.d.ts +24 -8
  29. package/errors/index.d.ts.map +1 -1
  30. package/errors/index.js +17 -19
  31. package/errors/index.js.map +1 -1
  32. package/invariantErrorCodes.js +1 -1
  33. package/link/batch-http/batch-http.cjs +23 -2
  34. package/link/batch-http/batch-http.cjs.map +1 -1
  35. package/link/batch-http/batch-http.cjs.native.js +23 -2
  36. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  37. package/link/batch-http/batchHttpLink.js +7 -2
  38. package/link/batch-http/batchHttpLink.js.map +1 -1
  39. package/link/core/types.d.ts +4 -0
  40. package/link/core/types.d.ts.map +1 -1
  41. package/link/core/types.js.map +1 -1
  42. package/link/http/createHttpLink.d.ts.map +1 -1
  43. package/link/http/createHttpLink.js +21 -20
  44. package/link/http/createHttpLink.js.map +1 -1
  45. package/link/http/http.cjs +59 -30
  46. package/link/http/http.cjs.map +1 -1
  47. package/link/http/http.cjs.native.js +59 -30
  48. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  49. package/link/http/parseAndCheckHttpResponse.js +34 -14
  50. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  51. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  52. package/link/http/selectHttpOptionsAndBody.js +2 -1
  53. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  54. package/link/subscriptions/index.d.ts.map +1 -1
  55. package/link/subscriptions/index.js +10 -5
  56. package/link/subscriptions/index.js.map +1 -1
  57. package/link/subscriptions/subscriptions.cjs +9 -4
  58. package/link/subscriptions/subscriptions.cjs.map +1 -1
  59. package/link/subscriptions/subscriptions.cjs.native.js +9 -4
  60. package/link/utils/filterOperationVariables.d.ts +5 -0
  61. package/link/utils/filterOperationVariables.d.ts.map +1 -0
  62. package/link/utils/filterOperationVariables.js +18 -0
  63. package/link/utils/filterOperationVariables.js.map +1 -0
  64. package/link/utils/index.d.ts +1 -0
  65. package/link/utils/index.d.ts.map +1 -1
  66. package/link/utils/index.js +1 -0
  67. package/link/utils/index.js.map +1 -1
  68. package/link/utils/utils.cjs +18 -0
  69. package/link/utils/utils.cjs.map +1 -1
  70. package/link/utils/utils.cjs.native.js +18 -0
  71. package/package.json +17 -17
  72. package/react/cache/QuerySubscription.js +1 -1
  73. package/react/cache/QuerySubscription.js.map +1 -1
  74. package/react/cache/SuspenseCache.d.ts +3 -2
  75. package/react/cache/SuspenseCache.d.ts.map +1 -1
  76. package/react/cache/SuspenseCache.js +6 -7
  77. package/react/cache/SuspenseCache.js.map +1 -1
  78. package/react/hooks/hooks.cjs +61 -84
  79. package/react/hooks/hooks.cjs.map +1 -1
  80. package/react/hooks/hooks.cjs.native.js +61 -84
  81. package/react/hooks/internal/__use.d.ts +3 -1
  82. package/react/hooks/internal/__use.d.ts.map +1 -1
  83. package/react/hooks/internal/__use.js +16 -12
  84. package/react/hooks/internal/__use.js.map +1 -1
  85. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  86. package/react/hooks/useLazyQuery.js +13 -22
  87. package/react/hooks/useLazyQuery.js.map +1 -1
  88. package/react/hooks/useQuery.d.ts +3 -3
  89. package/react/hooks/useQuery.d.ts.map +1 -1
  90. package/react/hooks/useQuery.js +26 -25
  91. package/react/hooks/useQuery.js.map +1 -1
  92. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  93. package/react/hooks/useSuspenseQuery.js +6 -2
  94. package/react/hooks/useSuspenseQuery.js.map +1 -1
  95. package/react/index.d.ts +1 -1
  96. package/react/index.d.ts.map +1 -1
  97. package/react/index.js +1 -1
  98. package/react/index.js.map +1 -1
  99. package/react/react.cjs +7 -22
  100. package/react/react.cjs.map +1 -1
  101. package/react/react.cjs.native.js +7 -22
  102. package/react/types/types.d.ts +1 -0
  103. package/react/types/types.d.ts.map +1 -1
  104. package/react/types/types.js.map +1 -1
  105. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  106. package/testing/react/MockedProvider.d.ts +1 -1
  107. package/testing/react/MockedProvider.d.ts.map +1 -1
  108. package/testing/react/MockedProvider.js +7 -6
  109. package/testing/react/MockedProvider.js.map +1 -1
  110. package/testing/testing.cjs +8 -124
  111. package/testing/testing.cjs.map +1 -1
  112. package/testing/testing.cjs.native.js +8 -124
  113. package/utilities/common/incrementalResult.d.ts +2 -1
  114. package/utilities/common/incrementalResult.d.ts.map +1 -1
  115. package/utilities/common/incrementalResult.js +4 -0
  116. package/utilities/common/incrementalResult.js.map +1 -1
  117. package/utilities/common/mergeOptions.d.ts +1 -1
  118. package/utilities/common/mergeOptions.d.ts.map +1 -1
  119. package/utilities/common/mergeOptions.js.map +1 -1
  120. package/utilities/common/objects.d.ts +1 -0
  121. package/utilities/common/objects.d.ts.map +1 -1
  122. package/utilities/common/objects.js +6 -0
  123. package/utilities/common/objects.js.map +1 -1
  124. package/utilities/common/omitDeep.d.ts +3 -0
  125. package/utilities/common/omitDeep.d.ts.map +1 -0
  126. package/utilities/common/omitDeep.js +42 -0
  127. package/utilities/common/omitDeep.js.map +1 -0
  128. package/utilities/common/stripTypename.d.ts +2 -0
  129. package/utilities/common/stripTypename.d.ts.map +1 -0
  130. package/utilities/common/stripTypename.js +5 -0
  131. package/utilities/common/stripTypename.js.map +1 -0
  132. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  133. package/utilities/graphql/storeUtils.js +1 -0
  134. package/utilities/graphql/storeUtils.js.map +1 -1
  135. package/utilities/graphql/transform.d.ts.map +1 -1
  136. package/utilities/graphql/transform.js +26 -16
  137. package/utilities/graphql/transform.js.map +1 -1
  138. package/utilities/index.d.ts +4 -0
  139. package/utilities/index.d.ts.map +1 -1
  140. package/utilities/index.js +3 -0
  141. package/utilities/index.js.map +1 -1
  142. package/utilities/types/DeepOmit.d.ts +9 -0
  143. package/utilities/types/DeepOmit.d.ts.map +1 -0
  144. package/utilities/types/DeepOmit.js +2 -0
  145. package/utilities/types/DeepOmit.js.map +1 -0
  146. package/utilities/utilities.cjs +111 -15
  147. package/utilities/utilities.cjs.map +1 -1
  148. package/utilities/utilities.cjs.native.js +111 -15
  149. package/version.js +1 -1
  150. package/react/hooks/compareResults.d.ts +0 -3
  151. package/react/hooks/compareResults.d.ts.map +0 -1
  152. package/react/hooks/compareResults.js.map +0 -1
@@ -143,6 +143,12 @@ function getFragmentFromSelection(selection, fragmentMap) {
143
143
  function isNonNullObject(obj) {
144
144
  return obj !== null && typeof obj === 'object';
145
145
  }
146
+ function isPlainObject(obj) {
147
+ return (obj !== null &&
148
+ typeof obj === 'object' &&
149
+ (Object.getPrototypeOf(obj) === Object.prototype ||
150
+ Object.getPrototypeOf(obj) === null));
151
+ }
146
152
 
147
153
  function makeReference(id) {
148
154
  return { __ref: String(id) };
@@ -250,6 +256,7 @@ var KNOWN_DIRECTIVES = [
250
256
  'client',
251
257
  'rest',
252
258
  'export',
259
+ 'nonreactive',
253
260
  ];
254
261
  var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
255
262
  if (args &&
@@ -448,19 +455,30 @@ function nullIfDocIsEmpty(doc) {
448
455
  ? null
449
456
  : doc;
450
457
  }
451
- function getDirectiveMatcher(directives) {
452
- var nameSet = new Set();
453
- var tests = [];
454
- directives.forEach(function (directive) {
455
- if (directive.name) {
456
- nameSet.add(directive.name);
457
- }
458
- else if (directive.test) {
459
- tests.push(directive.test);
458
+ function getDirectiveMatcher(configs) {
459
+ var names = new Map();
460
+ var tests = new Map();
461
+ configs.forEach(function (directive) {
462
+ if (directive) {
463
+ if (directive.name) {
464
+ names.set(directive.name, directive);
465
+ }
466
+ else if (directive.test) {
467
+ tests.set(directive.test, directive);
468
+ }
460
469
  }
461
470
  });
462
- return function (directive) { return (nameSet.has(directive.name.value) ||
463
- tests.some(function (test) { return test(directive); })); };
471
+ return function (directive) {
472
+ var config = names.get(directive.name.value);
473
+ if (!config && tests.size) {
474
+ tests.forEach(function (testConfig, test) {
475
+ if (test(directive)) {
476
+ config = testConfig;
477
+ }
478
+ });
479
+ }
480
+ return config;
481
+ };
464
482
  }
465
483
  function makeInUseGetterFunction(defaultKey) {
466
484
  var map = new Map();
@@ -477,6 +495,7 @@ function makeInUseGetterFunction(defaultKey) {
477
495
  };
478
496
  }
479
497
  function removeDirectivesFromDocument(directives, doc) {
498
+ checkDocument(doc);
480
499
  var getInUseByOperationName = makeInUseGetterFunction("");
481
500
  var getInUseByFragmentName = makeInUseGetterFunction("");
482
501
  var getInUse = function (ancestors) {
@@ -500,10 +519,8 @@ function removeDirectivesFromDocument(directives, doc) {
500
519
  }
501
520
  }
502
521
  var directiveMatcher = getDirectiveMatcher(directives);
503
- var hasRemoveDirective = directives.some(function (directive) { return directive.remove; });
504
- var shouldRemoveField = function (nodeDirectives) { return (hasRemoveDirective &&
505
- nodeDirectives &&
506
- nodeDirectives.some(directiveMatcher)); };
522
+ var shouldRemoveField = function (nodeDirectives) { return (isNonEmptyArray(nodeDirectives) &&
523
+ nodeDirectives.map(directiveMatcher).some(function (config) { return config && config.remove; })); };
507
524
  var originalFragmentDefsByPath = new Map();
508
525
  var firstVisitMadeChanges = false;
509
526
  var fieldOrInlineFragmentVisitor = {
@@ -984,6 +1001,31 @@ function makeEmptyData() {
984
1001
  };
985
1002
  }
986
1003
 
1004
+ function isStatefulPromise(promise) {
1005
+ return 'status' in promise;
1006
+ }
1007
+ function wrapPromiseWithState(promise) {
1008
+ if (isStatefulPromise(promise)) {
1009
+ return promise;
1010
+ }
1011
+ var pendingPromise = promise;
1012
+ pendingPromise.status = 'pending';
1013
+ pendingPromise.then(function (value) {
1014
+ if (pendingPromise.status === 'pending') {
1015
+ var fulfilledPromise = pendingPromise;
1016
+ fulfilledPromise.status = 'fulfilled';
1017
+ fulfilledPromise.value = value;
1018
+ }
1019
+ }, function (reason) {
1020
+ if (pendingPromise.status === 'pending') {
1021
+ var rejectedPromise = pendingPromise;
1022
+ rejectedPromise.status = 'rejected';
1023
+ rejectedPromise.reason = reason;
1024
+ }
1025
+ });
1026
+ return promise;
1027
+ }
1028
+
987
1029
  var toString = Object.prototype.toString;
988
1030
  function cloneDeep(value) {
989
1031
  return cloneDeepHelper(value);
@@ -1266,6 +1308,9 @@ function isExecutionPatchResult(value) {
1266
1308
  return (isExecutionPatchIncrementalResult(value) ||
1267
1309
  isExecutionPatchInitialResult(value));
1268
1310
  }
1311
+ function isApolloPayloadResult(value) {
1312
+ return isNonNullObject(value) && "payload" in value;
1313
+ }
1269
1314
  function mergeIncrementalData(prevResult, result) {
1270
1315
  var mergedData = prevResult;
1271
1316
  var merger = new DeepMerger();
@@ -1364,6 +1409,51 @@ function isNodeReadableStream(value) {
1364
1409
  return !!value.pipe;
1365
1410
  }
1366
1411
 
1412
+ function omitDeep(value, key) {
1413
+ return __omitDeep(value, key);
1414
+ }
1415
+ function __omitDeep(value, key, known) {
1416
+ if (known === void 0) { known = new Map(); }
1417
+ if (known.has(value)) {
1418
+ return known.get(value);
1419
+ }
1420
+ var modified = false;
1421
+ if (Array.isArray(value)) {
1422
+ var array_1 = [];
1423
+ known.set(value, array_1);
1424
+ value.forEach(function (value, index) {
1425
+ var result = __omitDeep(value, key, known);
1426
+ modified || (modified = result !== value);
1427
+ array_1[index] = result;
1428
+ });
1429
+ if (modified) {
1430
+ return array_1;
1431
+ }
1432
+ }
1433
+ else if (isPlainObject(value)) {
1434
+ var obj_1 = Object.create(Object.getPrototypeOf(value));
1435
+ known.set(value, obj_1);
1436
+ Object.keys(value).forEach(function (k) {
1437
+ if (k === key) {
1438
+ modified = true;
1439
+ }
1440
+ else {
1441
+ var result = __omitDeep(value[k], key, known);
1442
+ modified || (modified = result !== value[k]);
1443
+ obj_1[k] = result;
1444
+ }
1445
+ });
1446
+ if (modified) {
1447
+ return obj_1;
1448
+ }
1449
+ }
1450
+ return value;
1451
+ }
1452
+
1453
+ function stripTypename(value) {
1454
+ return omitDeep(value, '__typename');
1455
+ }
1456
+
1367
1457
  exports.DEV = globals.DEV;
1368
1458
  exports.maybe = globals.maybe;
1369
1459
  exports.Observable = zenObservableTs.Observable;
@@ -1404,6 +1494,7 @@ exports.hasAllDirectives = hasAllDirectives;
1404
1494
  exports.hasAnyDirectives = hasAnyDirectives;
1405
1495
  exports.hasClientExports = hasClientExports;
1406
1496
  exports.hasDirectives = hasDirectives;
1497
+ exports.isApolloPayloadResult = isApolloPayloadResult;
1407
1498
  exports.isArray = isArray;
1408
1499
  exports.isAsyncIterableIterator = isAsyncIterableIterator;
1409
1500
  exports.isBlob = isBlob;
@@ -1417,8 +1508,10 @@ exports.isNodeReadableStream = isNodeReadableStream;
1417
1508
  exports.isNodeResponse = isNodeResponse;
1418
1509
  exports.isNonEmptyArray = isNonEmptyArray;
1419
1510
  exports.isNonNullObject = isNonNullObject;
1511
+ exports.isPlainObject = isPlainObject;
1420
1512
  exports.isReadableStream = isReadableStream;
1421
1513
  exports.isReference = isReference;
1514
+ exports.isStatefulPromise = isStatefulPromise;
1422
1515
  exports.isStreamableBlob = isStreamableBlob;
1423
1516
  exports.iterateObserversSafely = iterateObserversSafely;
1424
1517
  exports.makeReference = makeReference;
@@ -1429,6 +1522,7 @@ exports.mergeDeepArray = mergeDeepArray;
1429
1522
  exports.mergeIncrementalData = mergeIncrementalData;
1430
1523
  exports.mergeOptions = mergeOptions;
1431
1524
  exports.offsetLimitPagination = offsetLimitPagination;
1525
+ exports.omitDeep = omitDeep;
1432
1526
  exports.relayStylePagination = relayStylePagination;
1433
1527
  exports.removeArgumentsFromDocument = removeArgumentsFromDocument;
1434
1528
  exports.removeClientSetsFromDocument = removeClientSetsFromDocument;
@@ -1439,5 +1533,7 @@ exports.resultKeyNameFromField = resultKeyNameFromField;
1439
1533
  exports.shouldInclude = shouldInclude;
1440
1534
  exports.storeKeyNameFromField = storeKeyNameFromField;
1441
1535
  exports.stringifyForDisplay = stringifyForDisplay;
1536
+ exports.stripTypename = stripTypename;
1442
1537
  exports.valueToObjectRepresentation = valueToObjectRepresentation;
1538
+ exports.wrapPromiseWithState = wrapPromiseWithState;
1443
1539
  //# sourceMappingURL=utilities.cjs.map