Currently, the package allows to define models only for es5 modules:
module.exports = {
fields:{
name : "text",
surname : "text",
age : "int",
created : "timestamp"
},
key:["name"]
}
Need to support es6 usage as well:
exports default {
fields:{
name : "text",
surname : "text",
age : "int",
created : "timestamp"
},
key:["name"]
}
This means that now models can be written on typescript and transpiled to js,
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
fields:{
name : "text",
surname : "text",
age : "int",
created : "timestamp"
},
key:["name"]
};
When the package tries to load models like the last one, fields cannot be found because is one level deep than expected and the following error will be displayed:
Unhandled rejection apollo.model.validator.invalidschema: Schema must contain a non-empty "fields" map object
WHAT is this pull request doing?
Adds support to es6 models definition by setting the modelSchema at the expected level.
WHY are these changes introduced?
Currently, the package allows to define models only for
es5
modules:Need to support
es6
usage as well:This means that now models can be written on typescript and transpiled to js,
When the package tries to load models like the last one, fields cannot be found because is one level deep than expected and the following error will be displayed:
Unhandled rejection apollo.model.validator.invalidschema: Schema must contain a non-empty "fields" map object
WHAT is this pull request doing?
Adds support to es6 models definition by setting the
modelSchema
at the expected level.