@coderich/autograph 0.13.93 → 0.13.95

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderich/autograph",
3
3
  "main": "index.js",
4
- "version": "0.13.93",
4
+ "version": "0.13.95",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -12,7 +12,8 @@
12
12
  "scripts": {
13
13
  "test": "NODE_OPTIONS=\"--stack-trace-limit=1000\" jest --config=jest.config.js",
14
14
  "lint": "eslint ./",
15
- "dev": "coderich-dev"
15
+ "dev": "coderich-dev",
16
+ "clinic": "clinic flame -- node ./test/server"
16
17
  },
17
18
  "dependencies": {
18
19
  "@coderich/util": "1.2.1",
@@ -35,6 +36,7 @@
35
36
  "@coderich/autograph-db-tests": "*",
36
37
  "@coderich/autograph-mongodb": "*",
37
38
  "@graphql-tools/schema": "10.0.0",
39
+ "clinic": "13.0.0",
38
40
  "graphql": "16.8.1",
39
41
  "mongodb": "5.9.2",
40
42
  "mongodb-memory-server": "8.13.0"
@@ -297,24 +297,21 @@ module.exports = class Resolver {
297
297
  }
298
298
 
299
299
  #createSystemEvent($query, thunk = () => {}) {
300
- let tquery = $query.transform(false);
301
- let query = tquery.toObject();
300
+ const tquery = $query.transform(false);
301
+ const query = tquery.toObject();
302
302
  const type = query.isMutation ? 'Mutation' : 'Query';
303
- let event = this.#createEvent(query);
303
+ const event = this.#createEvent(query);
304
304
 
305
305
  return Emitter.emit(`pre${type}`, event).then(async (resultEarly) => {
306
306
  if (resultEarly !== undefined) return resultEarly; // Nothing to validate/transform
307
307
  // if (query.crud === 'update' && Util.isEqual({ added: {}, updated: {}, deleted: {} }, Util.changeset(query.doc, query.input))) return query.doc;
308
- tquery = $query.transform(false);
309
- query = tquery.toObject();
308
+
310
309
  if (['create', 'update'].includes(query.crud)) {
311
310
  tquery.validate(); // Transformation sets $thunks
312
311
  await Promise.all([...query.input.$thunks]);
313
- event = this.#createEvent(query);
314
312
  await Emitter.emit('validate', event);
315
- } else {
316
- event = this.#createEvent(query);
317
313
  }
314
+
318
315
  return thunk(tquery);
319
316
  }).then((result) => {
320
317
  event.result = result; // backwards compat
@@ -331,7 +328,7 @@ module.exports = class Resolver {
331
328
 
332
329
  // Backwards compat
333
330
  Object.assign(event, query);
334
- query.match = query.where;
331
+ query.match = event.args.where;
335
332
  query.toObject = () => query;
336
333
  event.merged = event.input;
337
334
  event.input = event.args?.input;
@@ -17,7 +17,7 @@ module.exports = class Transformer {
17
17
  const result = this.#config.shape[prop].reduce((value, t) => {
18
18
  previousValue = value;
19
19
  if (typeof t === 'function') return Util.uvl(t({ startValue, value, ...this.#config.args }), value);
20
- prop = t;
20
+ prop = t; // rename key
21
21
  return value;
22
22
  }, startValue);
23
23