simple-graphql
Version:
The simple way to generates GraphQL schemas and Sequelize models from your models definition.
32 lines • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
exports.default = {
name: 'version',
defaultOptions: {
enable: true
},
priority: 100,
description: 'Add version field to Schema',
applyToSchema: (schema, options, schemas) => {
if (schema instanceof index_1.SGSchema) {
const versionConfig = (schema.options.tableOptions || {}).version;
if (versionConfig === true || typeof versionConfig === 'string') {
const versionField = typeof versionConfig === 'string' ? versionConfig : 'version';
schema.fields({
[versionField]: {
type: 'Integer',
nullable: false,
metadata: {
graphql: {
initializable: false,
updatable: false
}
}
}
});
}
}
}
};
//# sourceMappingURL=versionPlugin.js.map