@coderich/autograph 0.13.41 → 0.13.42
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/package.json +1 -1
- package/src/data/DataLoader.js +5 -0
- package/src/data/Resolver.js +16 -1
package/package.json
CHANGED
package/src/data/DataLoader.js
CHANGED
|
@@ -50,6 +50,11 @@ module.exports = class Loader {
|
|
|
50
50
|
const values = Array.from(new Set(batches.map(batch => batch.values).flat()));
|
|
51
51
|
const $query = { ...batches[0].$query, op: 'findMany', where: { [key]: values } };
|
|
52
52
|
|
|
53
|
+
//
|
|
54
|
+
if (values.length < 3) {
|
|
55
|
+
return batches.map(batch => this.#model.source.client.resolve(batch.$query).then(data => ({ data, ...batch })));
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
// Collect all the $values (Regular Expressions) to match doc (result) data by
|
|
54
59
|
const $values = Array.from(new Set(batches.map(batch => batch.$values).flat()));
|
|
55
60
|
const docsByRegExpKey = $values.reduce((map, re) => map.set(re, []), new Map());
|
package/src/data/Resolver.js
CHANGED
|
@@ -205,7 +205,22 @@ module.exports = class Resolver {
|
|
|
205
205
|
return this.toResultSet(model, results);
|
|
206
206
|
});
|
|
207
207
|
} else {
|
|
208
|
-
thunk = tquery =>
|
|
208
|
+
thunk = (tquery) => {
|
|
209
|
+
const { where, op } = query.toObject();
|
|
210
|
+
const values = Object.values(where);
|
|
211
|
+
const $values = values.flat();
|
|
212
|
+
const skipQuery = values.length && (!$values.length || $values.includes(undefined));
|
|
213
|
+
|
|
214
|
+
if (skipQuery) {
|
|
215
|
+
switch (op) {
|
|
216
|
+
case 'count': return Promise.resolve(0);
|
|
217
|
+
case 'findMany': return Promise.resolve([]);
|
|
218
|
+
default: return Promise.resolve(null);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return this.#dataLoaders[model].resolve(tquery);
|
|
223
|
+
};
|
|
209
224
|
}
|
|
210
225
|
|
|
211
226
|
return this.#createSystemEvent(query, (tquery) => {
|