"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HasManyDirectiveDDBFieldsTransformer = void 0;
const resolvers_1 = require("../resolvers");
const utils_1 = require("../utils");
class HasManyDirectiveDDBFieldsTransformer {
    constructor(dbType) {
        this.prepare = (context, config) => {
            const modelName = config.object.name.value;
            (0, utils_1.registerHasManyForeignKeyMappings)({
                transformParameters: context.transformParameters,
                resourceHelper: context.resourceHelper,
                thisTypeName: modelName,
                thisFieldName: config.field.name.value,
                relatedType: config.relatedType,
            });
        };
        this.transformSchema = (context, config) => {
            config.relatedTypeIndex = (0, utils_1.getRelatedTypeIndex)(config, context, config.indexName);
        };
        this.generateResolvers = (context, config) => {
            (0, resolvers_1.updateTableForConnection)(config, context);
        };
        this.validate = (context, config) => {
            (0, utils_1.ensureFieldsArray)(config);
            config.fieldNodes = (0, utils_1.getFieldsNodes)(config, context);
        };
        this.dbType = dbType;
    }
}
exports.HasManyDirectiveDDBFieldsTransformer = HasManyDirectiveDDBFieldsTransformer;
//# sourceMappingURL=has-many-directive-ddb-fields-transformer.js.map