File tree 8 files changed +47
-44
lines changed
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 {
56
56
*/
57
57
static isConnection ( field : Field ) : boolean ;
58
58
/**
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.
61
64
* @param {Model } model
62
65
*/
63
66
static augment ( model : Model ) : void ;
Original file line number Diff line number Diff line change @@ -7940,17 +7940,17 @@ var Model = /** @class */ (function () {
7940
7940
field instanceof context.components.MorphOne);
7941
7941
};
7942
7942
/**
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.
7945
7948
* @param {Model} model
7946
7949
*/
7947
7950
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);
7954
7954
};
7955
7955
/**
7956
7956
* Returns the related model for a relation.
Original file line number Diff line number Diff line change @@ -7824,17 +7824,17 @@ class Model {
7824
7824
field instanceof context.components.MorphOne);
7825
7825
}
7826
7826
/**
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.
7829
7832
* @param {Model} model
7830
7833
*/
7831
7834
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);
7838
7838
}
7839
7839
/**
7840
7840
* Returns the related model for a relation.
Original file line number Diff line number Diff line change @@ -7824,17 +7824,17 @@ class Model {
7824
7824
field instanceof context.components.MorphOne);
7825
7825
}
7826
7826
/**
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.
7829
7832
* @param {Model} model
7830
7833
*/
7831
7834
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);
7838
7838
}
7839
7839
/**
7840
7840
* Returns the related model for a relation.
Original file line number Diff line number Diff line change @@ -7824,17 +7824,17 @@ class Model {
7824
7824
field instanceof context.components.MorphOne);
7825
7825
}
7826
7826
/**
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.
7829
7832
* @param {Model} model
7830
7833
*/
7831
7834
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);
7838
7838
}
7839
7839
/**
7840
7840
* 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) {
7939
7939
field instanceof context.components.MorphOne);
7940
7940
};
7941
7941
/**
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.
7944
7947
* @param {Model} model
7945
7948
*/
7946
7949
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);
7953
7953
};
7954
7954
/**
7955
7955
* Returns the related model for a relation.
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @vuex-orm/plugin-graphql" ,
3
- "version" : " 1.0.0-rc.39 " ,
3
+ "version" : " 1.0.0-rc.40 " ,
4
4
"description" : " Vuex-ORM persistence plugin to sync the store against a GraphQL API." ,
5
5
"main" : " dist/vuex-orm-graphql.cjs.js" ,
6
6
"browser" : " dist/vuex-orm-graphql.esm.js" ,
You can’t perform that action at this time.
0 commit comments