@routier/core 0.0.2 → 0.0.4
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 +11 -2
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.js +11 -2
- package/dist/plugins/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5390,6 +5390,9 @@ class OptimisticReplicationDbPlugin {
|
|
|
5390
5390
|
const sourcePlugin = this.plugins.source;
|
|
5391
5391
|
const collectionSize = getMemoryPluginCollectionSize(this.plugins.read, event.operation.schema);
|
|
5392
5392
|
if (collectionSize === 0 && cache.has(WAS_OPTIMISTIC_DB_HYDRATED_KEY) === false) {
|
|
5393
|
+
// Notify the cache that the db was hydrated right away
|
|
5394
|
+
cache.add(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5395
|
+
console.log('[ROUTIER] - Optimistic Query', cache);
|
|
5393
5396
|
// nothing is hydrated, let's try and hydrate before querying
|
|
5394
5397
|
// Memory plugin might not be hydrated, lets hydrate it for the targeted schema only,
|
|
5395
5398
|
// Other queries will do the same and hydrate if needed
|
|
@@ -5402,14 +5405,20 @@ class OptimisticReplicationDbPlugin {
|
|
|
5402
5405
|
operation: _query__WEBPACK_IMPORTED_MODULE_1__.Query.EMPTY(event.operation.schema)
|
|
5403
5406
|
}, (sourceResult) => {
|
|
5404
5407
|
if (sourceResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
|
|
5408
|
+
// Notify that hydration failed
|
|
5409
|
+
cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5405
5410
|
done(sourceResult);
|
|
5406
5411
|
return;
|
|
5407
5412
|
}
|
|
5408
5413
|
if (sourceResult == null || (Array.isArray(sourceResult.data) && sourceResult.data.length === 0)) {
|
|
5414
|
+
// Notify that hydration had no data
|
|
5415
|
+
cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5409
5416
|
done(sourceResult);
|
|
5410
5417
|
return;
|
|
5411
5418
|
}
|
|
5412
5419
|
if (Array.isArray(sourceResult.data) === false) {
|
|
5420
|
+
// Notify that hydration failed
|
|
5421
|
+
cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5413
5422
|
done(_results__WEBPACK_IMPORTED_MODULE_2__.PluginEventResult.error(event.id, "Query result is not an array"));
|
|
5414
5423
|
return;
|
|
5415
5424
|
}
|
|
@@ -5424,11 +5433,11 @@ class OptimisticReplicationDbPlugin {
|
|
|
5424
5433
|
source: "collection",
|
|
5425
5434
|
}, (readPersistResult) => {
|
|
5426
5435
|
if (readPersistResult.ok === _results__WEBPACK_IMPORTED_MODULE_2__.Result.ERROR) {
|
|
5436
|
+
// Notify that hydration failed
|
|
5437
|
+
cache.delete(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5427
5438
|
done(readPersistResult);
|
|
5428
5439
|
return;
|
|
5429
5440
|
}
|
|
5430
|
-
// Notify the cache that the db was hydrated
|
|
5431
|
-
cache.add(WAS_OPTIMISTIC_DB_HYDRATED_KEY);
|
|
5432
5441
|
// requery the read plugin
|
|
5433
5442
|
readPlugin.query(event, done);
|
|
5434
5443
|
});
|