simple-graphql
Version:
The simple way to generates GraphQL schemas and Sequelize models from your models definition.
53 lines • 1.75 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
exports.default = {
name: 'timestamp',
defaultOptions: {
enable: true
},
priority: 100,
description: 'Add createdAt/updatedAt field to Schema',
applyToSchema: (schema, options, schemas) => {
var _a, _b;
if (schema instanceof index_1.SGSchema) {
schema.fields({
createdAt: {
type: 'Date',
nullable: true,
metadata: {
graphql: {
initializable: false,
updatable: false
}
}
},
updatedAt: {
type: 'Date',
nullable: true,
metadata: {
graphql: {
initializable: false,
updatable: false
}
}
}
});
if ((_b = (_a = schema.options) === null || _a === void 0 ? void 0 : _a.tableOptions) === null || _b === void 0 ? void 0 : _b.paranoid) {
schema.fields({
deletedAt: {
type: 'Date',
nullable: true,
metadata: {
graphql: {
initializable: false,
updatable: false
}
}
}
});
}
}
}
};
//# sourceMappingURL=timestampPlugin.js.map