@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/index.js
CHANGED
|
@@ -5364,6 +5364,8 @@ const getMemoryPluginCollectionSize = (plugin, schema) => {
|
|
|
5364
5364
|
}
|
|
5365
5365
|
throw new Error("Cannot get size of collection for MemoryPlugin, not an instance of MemoryPlugin");
|
|
5366
5366
|
};
|
|
5367
|
+
const WAS_OPTIMISTIC_DB_HYDRATED_KEY = "was-hydrated";
|
|
5368
|
+
const cache = new Set();
|
|
5367
5369
|
class OptimisticReplicationDbPlugin {
|
|
5368
5370
|
plugins;
|
|
5369
5371
|
constructor(plugins) {
|
|
@@ -5387,7 +5389,7 @@ class OptimisticReplicationDbPlugin {
|
|
|
5387
5389
|
const readPlugin = this.plugins.read;
|
|
5388
5390
|
const sourcePlugin = this.plugins.source;
|
|
5389
5391
|
const collectionSize = getMemoryPluginCollectionSize(this.plugins.read, event.operation.schema);
|
|
5390
|
-
if (collectionSize === 0) {
|
|
5392
|
+
if (collectionSize === 0 && cache.has(WAS_OPTIMISTIC_DB_HYDRATED_KEY) === false) {
|
|
5391
5393
|
// nothing is hydrated, let's try and hydrate before querying
|
|
5392
5394
|
// Memory plugin might not be hydrated, lets hydrate it for the targeted schema only,
|
|
5393
5395
|
// Other queries will do the same and hydrate if needed
|
|
@@ -5425,6 +5427,8 @@ class OptimisticReplicationDbPlugin {
|
|
|
5425
5427
|
done(readPersistResult);
|
|
5426
5428
|
return;
|
|
5427
5429
|
}
|
|
5430
|
+
// Notify the cache that the db was hydrated
|
|
5431
|
+
cache.add(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5428
5432
|
// requery the read plugin
|
|
5429
5433
|
readPlugin.query(event, done);
|
|
5430
5434
|
});
|