"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BelongsToDirectiveDDBFieldsTransformer = void 0;
const utils_1 = require("../utils");
class BelongsToDirectiveDDBFieldsTransformer {
    constructor(dbType) {
        this.prepare = (context, config) => {
            if (config.relationType !== 'hasOne') {
                return;
            }
            const modelName = config.object.name.value;
            (0, utils_1.registerHasOneForeignKeyMappings)({
                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);
        };
        this.generateResolvers = (_context, _config) => {
            return;
        };
        this.validate = (context, config) => {
            (0, utils_1.ensureFieldsArray)(config);
            config.fieldNodes = (0, utils_1.getFieldsNodes)(config, context);
        };
        this.dbType = dbType;
    }
}
exports.BelongsToDirectiveDDBFieldsTransformer = BelongsToDirectiveDDBFieldsTransformer;
//# sourceMappingURL=belongs-to-directive-ddb-fields-transformer.js.map