@routier/core 0.0.2 → 0.0.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.
@@ -1514,6 +1514,8 @@ class OptimisticReplicationDbPlugin {
1514
1514
  const sourcePlugin = this.plugins.source;
1515
1515
  const collectionSize = getMemoryPluginCollectionSize(this.plugins.read, event.operation.schema);
1516
1516
  if (collectionSize === 0 && cache.has(WAS_OPTIMISTIC_DB_HYDRATED_KEY) === false) {
1517
+ // Notify the cache that the db was hydrated right away
1518
+ cache.add(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
1517
1519
  // nothing is hydrated, let's try and hydrate before querying
1518
1520
  // Memory plugin might not be hydrated, lets hydrate it for the targeted schema only,
1519
1521
  // Other queries will do the same and hydrate if needed
@@ -1526,14 +1528,20 @@ class OptimisticReplicationDbPlugin {
1526
1528
  operation: _query__WEBPACK_IMPORTED_MODULE_1__.Query.EMPTY(event.operation.schema)
1527
1529
  }, (sourceResult) => {
1528
1530
  if (sourceResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
1531
+ // Notify that hydration failed
1532
+ cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
1529
1533
  done(sourceResult);
1530
1534
  return;
1531
1535
  }
1532
1536
  if (sourceResult == null || (Array.isArray(sourceResult.data) && sourceResult.data.length === 0)) {
1537
+ // Notify that hydration had no data
1538
+ cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
1533
1539
  done(sourceResult);
1534
1540
  return;
1535
1541
  }
1536
1542
  if (Array.isArray(sourceResult.data) === false) {
1543
+ // Notify that hydration failed
1544
+ cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
1537
1545
  done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Query result is not an array"));
1538
1546
  return;
1539
1547
  }
@@ -1548,11 +1556,11 @@ class OptimisticReplicationDbPlugin {
1548
1556
  source: "collection",
1549
1557
  }, (readPersistResult) => {
1550
1558
  if (readPersistResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
1559
+ // Notify that hydration failed
1560
+ cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
1551
1561
  done(readPersistResult);
1552
1562
  return;
1553
1563
  }
1554
- // Notify the cache that the db was hydrated
1555
- cache.add(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
1556
1564
  // requery the read plugin
1557
1565
  readPlugin.query(event, done);
1558
1566
  });