@coderich/autograph 0.13.47 → 0.13.48

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.47",
4
+ "version": "0.13.48",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -527,11 +527,15 @@ module.exports = class Schema {
527
527
  });
528
528
 
529
529
  // Helper methods
530
+ const resolvePathCache = {};
530
531
  this.#schema.resolvePath = (path, prop = 'key') => {
531
- const [modelKey, ...fieldKeys] = path.split('.');
532
- const $model = Object.values(this.#schema.models).find(el => el[prop] === modelKey);
533
- if (!$model || !fieldKeys.length) return $model;
534
- return fieldKeys.reduce((parent, key) => Object.values(parent.fields || parent.model.fields).find(el => el[prop] === key) || parent, $model);
532
+ resolvePathCache[path] ??= (() => {
533
+ const [modelKey, ...fieldKeys] = path.split('.');
534
+ const $model = Object.values(this.#schema.models).find(el => el[prop] === modelKey);
535
+ if (!$model || !fieldKeys.length) return $model;
536
+ return fieldKeys.reduce((parent, key) => Object.values(parent.fields || parent.model.fields).find(el => el[prop] === key) || parent, $model);
537
+ })();
538
+ return resolvePathCache[path];
535
539
  };
536
540
 
537
541
  // Mutate typeDefs