"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const v4_1 = __importDefault(require("uuid/v4"));
const typeorm_1 = require("typeorm");
const entities_1 = require("../../../entities");
exports.createPublisher = {
    async createPublisher(_, { publisher: attrs, datasourceId }) {
        const repository = typeorm_1.getRepository(entities_1.Publisher);
        const newPublisher = Object.assign({ id: v4_1.default() }, attrs);
        const datasourceRepository = typeorm_1.getRepository(entities_1.DataSource);
        newPublisher.datasource = await datasourceRepository.findOne({
            id: datasourceId
        });
        return await repository.save(newPublisher);
    }
};
//# sourceMappingURL=create-publisher.js.map