@coderich/autograph 0.13.13 → 0.13.15

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.13",
4
+ "version": "0.13.15",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -63,6 +63,7 @@ module.exports = class Pipeline {
63
63
  Pipeline.define('createdAt', ({ value }) => value || new Date(), { ignoreNull: false });
64
64
  Pipeline.define('timestamp', () => Date.now(), { ignoreNull: false });
65
65
  Pipeline.define('dedupe', ({ value }) => uniqWith(value, (b, c) => hashObject(b) === hashObject(c)), { itemize: false });
66
+ Pipeline.define('toId', ({ model, value }) => model.source.idValue(value.id || value)); // Deprecate
66
67
 
67
68
  // Structures
68
69
  Pipeline.define('$instruct', params => Pipeline.resolve(params, 'instruct'), { ignoreNull: false });
@@ -280,8 +280,11 @@ module.exports = class Resolver {
280
280
  const event = { schema: this.#schema, context: this.#context, resolver: this, query };
281
281
 
282
282
  // Backwards compat
283
- query.match = { ...query.where };
283
+ Object.assign(event, query);
284
+ query.match = query.where;
284
285
  query.toObject = () => query;
286
+ event.merged = event.input;
287
+ event.input = event.args?.input;
285
288
 
286
289
  return Emitter.emit(`pre${type}`, event).then(async (resultEarly) => {
287
290
  if (resultEarly !== undefined) return resultEarly;
@@ -289,13 +292,16 @@ module.exports = class Resolver {
289
292
  if (query.isMutation) query.input = await tquery.pipeline('input', query.input, ['$finalize']);
290
293
  if (query.isMutation) await Emitter.emit('finalize', event);
291
294
  return thunk().then((result) => {
295
+ event.result = result; // backwards compat
292
296
  query.result = result;
293
297
  return Emitter.emit(`post${type}`, event);
294
298
  });
295
299
  }).then((result = query.result) => {
300
+ event.result = result; // backwards compat
296
301
  query.result = result;
297
302
  return Emitter.emit('preResponse', event);
298
303
  }).then((result = query.result) => {
304
+ event.result = result; // backwards compat
299
305
  query.result = result;
300
306
  return Emitter.emit('postResponse', event);
301
307
  }).then((result = query.result) => result).catch((e) => {
@@ -337,6 +337,8 @@ module.exports = class Schema {
337
337
  isField = false;
338
338
  } else if (node.kind === Kind.LIST_TYPE) {
339
339
  isList = false;
340
+ } else if (scalarKinds.includes(node.kind)) {
341
+ isField = false;
340
342
  }
341
343
  },
342
344
  });