@coderich/autograph 0.9.4 → 0.9.5
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/core/Resolver.js
CHANGED
|
@@ -58,8 +58,8 @@ module.exports = class Resolver {
|
|
|
58
58
|
default: {
|
|
59
59
|
// This is needed in SF tests...
|
|
60
60
|
const key = model.idKey();
|
|
61
|
-
const { where } = query.toDriver();
|
|
62
|
-
if (Object.prototype.hasOwnProperty.call(where, key) && where[key] == null) return Promise.resolve(null);
|
|
61
|
+
const { where, method } = query.toDriver();
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(where, key) && where[key] == null) return Promise.resolve(method === 'findMany' ? [] : null);
|
|
63
63
|
|
|
64
64
|
//
|
|
65
65
|
return this.loaders.get(`${model}`).load(query);
|
package/src/data/DataService.js
CHANGED
|
@@ -79,6 +79,18 @@ exports.spliceEmbeddedArray = async (query, doc, key, from, to) => {
|
|
|
79
79
|
|
|
80
80
|
// Pull
|
|
81
81
|
if (from) {
|
|
82
|
+
// key.split('.').reduce((prev, segment, i, arr) => {
|
|
83
|
+
// if (prev == null) return prev;
|
|
84
|
+
|
|
85
|
+
// return map(prev, (data) => {
|
|
86
|
+
// const $data = data[segment];
|
|
87
|
+
// if (i < (arr.length - 1)) return $data;
|
|
88
|
+
// remove($data, el => ($from || from).find(val => objectContaining(el, val)));
|
|
89
|
+
// return $data;
|
|
90
|
+
// });
|
|
91
|
+
// }, doc);
|
|
92
|
+
|
|
93
|
+
// return doc;
|
|
82
94
|
const data = { [key]: get(doc, key) || [] };
|
|
83
95
|
remove(data[key], el => $from.find(val => objectContaining(el, val)));
|
|
84
96
|
return data;
|
|
@@ -11,7 +11,7 @@ module.exports = (schema) => {
|
|
|
11
11
|
enum AutoGraphTransformEnum { ${Object.keys(Transformer.getInstances()).join(' ')} }
|
|
12
12
|
enum AutoGraphAuthzEnum { private protected public }
|
|
13
13
|
enum AutoGraphValueScopeEnum { self context }
|
|
14
|
-
enum AutoGraphOnDeleteEnum { cascade nullify restrict }
|
|
14
|
+
enum AutoGraphOnDeleteEnum { cascade nullify restrict defer }
|
|
15
15
|
enum AutoGraphIndexEnum { unique }
|
|
16
16
|
|
|
17
17
|
directive @model(
|
|
@@ -111,6 +111,11 @@ exports.resolveReferentialIntegrity = (query) => {
|
|
|
111
111
|
txn.match(ref).where($where).flags(flags).count().then(count => (count ? reject(new Error('Restricted')) : count));
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
|
+
case 'defer': {
|
|
115
|
+
// Defer to the embedded object
|
|
116
|
+
// Marks the field as an onDelete candidate otherwise it (and the embedded object) will get skipped
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
114
119
|
default: throw new Error(`Unknown onDelete operator: '${op}'`);
|
|
115
120
|
}
|
|
116
121
|
});
|