@coderich/autograph 0.10.23 → 0.10.24

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
  "author": "Richard Livolsi (coderich)",
4
- "version": "0.10.23",
4
+ "version": "0.10.24",
5
5
  "description": "AutoGraph",
6
6
  "keywords": [
7
7
  "graphql",
@@ -82,11 +82,17 @@ module.exports = class QueryResolver {
82
82
 
83
83
  return this.resolver.match(model).match(match).one({ required: true }).then((doc) => {
84
84
  const merged = mergeDeep(doc, input);
85
+ const docHash = hashObject(doc);
86
+ const skipUnchanged = get(flags, 'skipUnchanged');
85
87
 
86
88
  // Prevent udpates when no data has changed
87
- if (get(flags, 'skipUnchanged') && hashObject(doc) === hashObject(merged)) return doc;
89
+ if (skipUnchanged && docHash === hashObject(merged)) return doc;
88
90
 
89
91
  return createSystemEvent('Mutation', { query: query.doc(doc).merged(merged) }, async () => {
92
+ // Prevent udpates when no data has changed (because merged can be mutated)
93
+ if (skipUnchanged && docHash === hashObject(merged)) return doc;
94
+
95
+ // Process
90
96
  const payload = model.shapeObject(inputShape, merged, query);
91
97
  await model.validateObject(inputShape, payload, query.payload(payload));
92
98
  const $doc = model.shapeObject(docShape, payload, query, undefined, undefined, true);