File tree Expand file tree Collapse file tree 8 files changed +47
-44
lines changed Expand file tree Collapse file tree 8 files changed +47
-44
lines changed Original file line number Diff line number Diff line change @@ -56,8 +56,11 @@ export default class Model {
5656 */
5757 static isConnection ( field : Field ) : boolean ;
5858 /**
59- * Adds $isPersisted and other meta fields to the model by overwriting the fields() method.
60- * @todo is this a good way to add fields?
59+ * Adds $isPersisted and other meta fields to the model.
60+ *
61+ * TODO: This feels rather hacky currently and may break anytime the internal structure of
62+ * the core changes. Maybe in the future there will be a feature in the core that allows to add
63+ * those meta fields by plugins.
6164 * @param {Model } model
6265 */
6366 static augment ( model : Model ) : void ;
Original file line number Diff line number Diff line change @@ -7940,17 +7940,17 @@ var Model = /** @class */ (function () {
79407940 field instanceof context.components.MorphOne);
79417941 };
79427942 /**
7943- * Adds $isPersisted and other meta fields to the model by overwriting the fields() method.
7944- * @todo is this a good way to add fields?
7943+ * Adds $isPersisted and other meta fields to the model.
7944+ *
7945+ * TODO: This feels rather hacky currently and may break anytime the internal structure of
7946+ * the core changes. Maybe in the future there will be a feature in the core that allows to add
7947+ * those meta fields by plugins.
79457948 * @param {Model} model
79467949 */
79477950 Model.augment = function (model) {
7948- var originalFieldGenerator = model.baseModel.fields.bind(model.baseModel);
7949- model.baseModel.fields = function () {
7950- var originalFields = originalFieldGenerator();
7951- originalFields["$isPersisted"] = model.baseModel.boolean(false);
7952- return originalFields;
7953- };
7951+ var baseModel = model.baseModel;
7952+ baseModel.getFields();
7953+ baseModel.cachedFields[baseModel.entity]["$isPersisted"] = baseModel.boolean(false);
79547954 };
79557955 /**
79567956 * Returns the related model for a relation.
Original file line number Diff line number Diff line change @@ -7824,17 +7824,17 @@ class Model {
78247824 field instanceof context.components.MorphOne);
78257825 }
78267826 /**
7827- * Adds $isPersisted and other meta fields to the model by overwriting the fields() method.
7828- * @todo is this a good way to add fields?
7827+ * Adds $isPersisted and other meta fields to the model.
7828+ *
7829+ * TODO: This feels rather hacky currently and may break anytime the internal structure of
7830+ * the core changes. Maybe in the future there will be a feature in the core that allows to add
7831+ * those meta fields by plugins.
78297832 * @param {Model} model
78307833 */
78317834 static augment(model) {
7832- const originalFieldGenerator = model.baseModel.fields.bind(model.baseModel);
7833- model.baseModel.fields = () => {
7834- const originalFields = originalFieldGenerator();
7835- originalFields["$isPersisted"] = model.baseModel.boolean(false);
7836- return originalFields;
7837- };
7835+ let baseModel = model.baseModel;
7836+ baseModel.getFields();
7837+ baseModel.cachedFields[baseModel.entity]["$isPersisted"] = baseModel.boolean(false);
78387838 }
78397839 /**
78407840 * Returns the related model for a relation.
Original file line number Diff line number Diff line change @@ -7824,17 +7824,17 @@ class Model {
78247824 field instanceof context.components.MorphOne);
78257825 }
78267826 /**
7827- * Adds $isPersisted and other meta fields to the model by overwriting the fields() method.
7828- * @todo is this a good way to add fields?
7827+ * Adds $isPersisted and other meta fields to the model.
7828+ *
7829+ * TODO: This feels rather hacky currently and may break anytime the internal structure of
7830+ * the core changes. Maybe in the future there will be a feature in the core that allows to add
7831+ * those meta fields by plugins.
78297832 * @param {Model} model
78307833 */
78317834 static augment(model) {
7832- const originalFieldGenerator = model.baseModel.fields.bind(model.baseModel);
7833- model.baseModel.fields = () => {
7834- const originalFields = originalFieldGenerator();
7835- originalFields["$isPersisted"] = model.baseModel.boolean(false);
7836- return originalFields;
7837- };
7835+ let baseModel = model.baseModel;
7836+ baseModel.getFields();
7837+ baseModel.cachedFields[baseModel.entity]["$isPersisted"] = baseModel.boolean(false);
78387838 }
78397839 /**
78407840 * Returns the related model for a relation.
Original file line number Diff line number Diff line change @@ -7824,17 +7824,17 @@ class Model {
78247824 field instanceof context.components.MorphOne);
78257825 }
78267826 /**
7827- * Adds $isPersisted and other meta fields to the model by overwriting the fields() method.
7828- * @todo is this a good way to add fields?
7827+ * Adds $isPersisted and other meta fields to the model.
7828+ *
7829+ * TODO: This feels rather hacky currently and may break anytime the internal structure of
7830+ * the core changes. Maybe in the future there will be a feature in the core that allows to add
7831+ * those meta fields by plugins.
78297832 * @param {Model} model
78307833 */
78317834 static augment(model) {
7832- const originalFieldGenerator = model.baseModel.fields.bind(model.baseModel);
7833- model.baseModel.fields = () => {
7834- const originalFields = originalFieldGenerator();
7835- originalFields["$isPersisted"] = model.baseModel.boolean(false);
7836- return originalFields;
7837- };
7835+ let baseModel = model.baseModel;
7836+ baseModel.getFields();
7837+ baseModel.cachedFields[baseModel.entity]["$isPersisted"] = baseModel.boolean(false);
78387838 }
78397839 /**
78407840 * Returns the related model for a relation.
Original file line number Diff line number Diff line change @@ -7939,17 +7939,17 @@ var VuexORMGraphQLPlugin = (function (exports) {
79397939 field instanceof context.components.MorphOne);
79407940 };
79417941 /**
7942- * Adds $isPersisted and other meta fields to the model by overwriting the fields() method.
7943- * @todo is this a good way to add fields?
7942+ * Adds $isPersisted and other meta fields to the model.
7943+ *
7944+ * TODO: This feels rather hacky currently and may break anytime the internal structure of
7945+ * the core changes. Maybe in the future there will be a feature in the core that allows to add
7946+ * those meta fields by plugins.
79447947 * @param {Model} model
79457948 */
79467949 Model.augment = function (model) {
7947- var originalFieldGenerator = model.baseModel.fields.bind(model.baseModel);
7948- model.baseModel.fields = function () {
7949- var originalFields = originalFieldGenerator();
7950- originalFields["$isPersisted"] = model.baseModel.boolean(false);
7951- return originalFields;
7952- };
7950+ var baseModel = model.baseModel;
7951+ baseModel.getFields();
7952+ baseModel.cachedFields[baseModel.entity]["$isPersisted"] = baseModel.boolean(false);
79537953 };
79547954 /**
79557955 * Returns the related model for a relation.
Original file line number Diff line number Diff line change 11{
22 "name" : " @vuex-orm/plugin-graphql" ,
3- "version" : " 1.0.0-rc.39 " ,
3+ "version" : " 1.0.0-rc.40 " ,
44 "description" : " Vuex-ORM persistence plugin to sync the store against a GraphQL API." ,
55 "main" : " dist/vuex-orm-graphql.cjs.js" ,
66 "browser" : " dist/vuex-orm-graphql.esm.js" ,
You can’t perform that action at this time.
0 commit comments