@routier/core 0.0.1 → 0.0.2
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.
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.js +5 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/package.json +1 -1
package/dist/plugins/index.js
CHANGED
|
@@ -1488,6 +1488,8 @@ const getMemoryPluginCollectionSize = (plugin, schema) => {
|
|
|
1488
1488
|
}
|
|
1489
1489
|
throw new Error("Cannot get size of collection for MemoryPlugin, not an instance of MemoryPlugin");
|
|
1490
1490
|
};
|
|
1491
|
+
const WAS_OPTIMISTIC_DB_HYDRATED_KEY = "was-hydrated";
|
|
1492
|
+
const cache = new Set();
|
|
1491
1493
|
class OptimisticReplicationDbPlugin {
|
|
1492
1494
|
plugins;
|
|
1493
1495
|
constructor(plugins) {
|
|
@@ -1511,7 +1513,7 @@ class OptimisticReplicationDbPlugin {
|
|
|
1511
1513
|
const readPlugin = this.plugins.read;
|
|
1512
1514
|
const sourcePlugin = this.plugins.source;
|
|
1513
1515
|
const collectionSize = getMemoryPluginCollectionSize(this.plugins.read, event.operation.schema);
|
|
1514
|
-
if (collectionSize === 0) {
|
|
1516
|
+
if (collectionSize === 0 && cache.has(WAS_OPTIMISTIC_DB_HYDRATED_KEY) === false) {
|
|
1515
1517
|
// nothing is hydrated, let's try and hydrate before querying
|
|
1516
1518
|
// Memory plugin might not be hydrated, lets hydrate it for the targeted schema only,
|
|
1517
1519
|
// Other queries will do the same and hydrate if needed
|
|
@@ -1549,6 +1551,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
1549
1551
|
done(readPersistResult);
|
|
1550
1552
|
return;
|
|
1551
1553
|
}
|
|
1554
|
+
// Notify the cache that the db was hydrated
|
|
1555
|
+
cache.add(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
1552
1556
|
// requery the read plugin
|
|
1553
1557
|
readPlugin.query(event, done);
|
|
1554
1558
|
});
|