@coderich/autograph 0.10.31 → 0.10.32

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.31",
4
+ "version": "0.10.32",
5
5
  "description": "AutoGraph",
6
6
  "keywords": [
7
7
  "graphql",
@@ -30,7 +30,7 @@
30
30
  "ratchet": "ratchet"
31
31
  },
32
32
  "dependencies": {
33
- "@coderich/util": "0.1.12",
33
+ "@coderich/util": "0.1.13",
34
34
  "@hapi/boom": "^9.1.0",
35
35
  "dataloader": "^2.0.0",
36
36
  "deepmerge": "^4.2.2",
@@ -44,6 +44,7 @@ exports.resolveSortBy = (query) => {
44
44
  const { model, sort = {} } = query.toObject();
45
45
  const shape = model.getShape('create', 'sortBy');
46
46
  const $sort = model.shapeObject(shape, sort, query);
47
+ const deletions = [];
47
48
 
48
49
  // Because normalize casts the value (sometimes to an array) need special handling
49
50
  keyPaths($sort).forEach((path) => {
@@ -55,14 +56,17 @@ exports.resolveSortBy = (query) => {
55
56
 
56
57
  // If you need to sort by something that's in another FK document
57
58
  if (join) {
58
- delete $sort[attr];
59
+ deletions.push(attr); // Keep track of what to delete
59
60
  query.joins(Object.assign(join, { as: `_.${field}`, left: true }));
60
61
  path = `_.${path}`;
61
- } else {
62
- set($sort, path, val.toLowerCase() === 'asc' ? 1 : -1);
63
62
  }
63
+
64
+ set($sort, path, val.toLowerCase() === 'asc' ? 1 : -1);
64
65
  });
65
66
 
67
+ // Delete the sorts on the "base" collection because you're sorting by _.path.to.it (above)
68
+ deletions.forEach(attr => delete $sort[attr]);
69
+
66
70
  return $sort;
67
71
  };
68
72