@coderich/autograph 0.13.98 → 0.13.100
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
CHANGED
package/src/data/Resolver.js
CHANGED
|
@@ -26,6 +26,10 @@ module.exports = class Resolver {
|
|
|
26
26
|
Util.set(this.#context, `${this.#schema.namespace}.resolver`, this);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
getSchema() {
|
|
30
|
+
return this.#schema;
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
getContext() {
|
|
30
34
|
return this.#context;
|
|
31
35
|
}
|
|
@@ -68,7 +72,7 @@ module.exports = class Resolver {
|
|
|
68
72
|
* @returns {QueryResolver|QueryResolverTransaction} - An API to build and execute a query
|
|
69
73
|
*/
|
|
70
74
|
match(model) {
|
|
71
|
-
return this.#sessions.
|
|
75
|
+
return this.#sessions.at(-1)?.at(-1)?.match(model) ?? new QueryResolver({
|
|
72
76
|
resolver: this,
|
|
73
77
|
schema: this.#schema,
|
|
74
78
|
context: this.#context,
|
|
@@ -100,8 +104,8 @@ module.exports = class Resolver {
|
|
|
100
104
|
transaction(isolated = true, parent = this) {
|
|
101
105
|
if (isolated) return this.clone().transaction(false, parent);
|
|
102
106
|
|
|
103
|
-
const currSession = this.#sessions.
|
|
104
|
-
const currTransaction = currSession?.
|
|
107
|
+
const currSession = this.#sessions.at(-1);
|
|
108
|
+
const currTransaction = currSession?.at(-1);
|
|
105
109
|
const realTransaction = new Transaction({ resolver: this, schema: this.#schema, context: this.#context });
|
|
106
110
|
const thunks = currTransaction ? currSession.thunks : []; // If in a transaction, piggy back off session
|
|
107
111
|
|
|
@@ -190,7 +194,7 @@ module.exports = class Resolver {
|
|
|
190
194
|
async resolve(query) {
|
|
191
195
|
let thunk;
|
|
192
196
|
const { doc, model, crud, isMutation, flags } = query.toObject();
|
|
193
|
-
const currSession = this.#sessions.
|
|
197
|
+
const currSession = this.#sessions.at(-1);
|
|
194
198
|
|
|
195
199
|
if (isMutation) {
|
|
196
200
|
thunk = tquery => this.#schema.models[model].source.client.resolve(tquery.toDriver().toObject()).then((results) => {
|
|
@@ -332,7 +336,7 @@ module.exports = class Resolver {
|
|
|
332
336
|
query.match = event.args.where;
|
|
333
337
|
query.toObject = () => query;
|
|
334
338
|
event.merged = event.input;
|
|
335
|
-
event.input = event.args?.input;
|
|
339
|
+
event.input = Util.unflatten(event.args?.input, { safe: true });
|
|
336
340
|
event.doc ??= {};
|
|
337
341
|
|
|
338
342
|
return event;
|
|
@@ -66,6 +66,7 @@ module.exports = class QueryResolver extends QueryBuilder {
|
|
|
66
66
|
const args = { query: $query, resolver: this.#resolver, context: this.#context };
|
|
67
67
|
const values = get(this.#model.transformers.create.transform(input, args), key, []);
|
|
68
68
|
const $doc = Util.pathmap(key, doc, (arr) => {
|
|
69
|
+
if (arr == null) return arr;
|
|
69
70
|
return arr.filter(el => values.every(v => `${v}` !== `${el}`));
|
|
70
71
|
});
|
|
71
72
|
return this.#resolver.match(this.#model.name).id(doc.id).save({ [key]: get($doc, key) });
|
package/src/schema/Schema.js
CHANGED
|
@@ -495,7 +495,7 @@ module.exports = class Schema {
|
|
|
495
495
|
|
|
496
496
|
Util.traverse(Object.values($model.fields), (f, info) => {
|
|
497
497
|
const path = info.path.concat(f.name);
|
|
498
|
-
if (f.isEmbedded) return { value: f.model.fields, info: { path } };
|
|
498
|
+
if (f.isEmbedded) return { value: Object.values(f.model.fields), info: { path } };
|
|
499
499
|
if (f.isScalar) $model.ignorePaths.push(path.join('.'));
|
|
500
500
|
return null;
|
|
501
501
|
}, { path: [] });
|