UNPKG

graphql-transformer-core

Version:

A framework to transform from GraphQL SDL to AWS cloudFormation.

21 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTableNameForModel = void 0; const collectDirectives_1 = require("./collectDirectives"); const _1 = require("."); const directiveName = 'mapsTo'; function getTableNameForModel(sdl, modelName) { var _a, _b, _c; const directivesByType = (0, collectDirectives_1.collectDirectivesByType)(sdl); const mapsToDirective = (_a = directivesByType === null || directivesByType === void 0 ? void 0 : directivesByType[modelName]) === null || _a === void 0 ? void 0 : _a.find((directive) => directive.name.value === directiveName); if (!mapsToDirective) { return modelName; } const originalName = (_c = (_b = mapsToDirective.arguments.find((arg) => arg.name.value === 'name')) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.value; if (!originalName) { throw new _1.InvalidDirectiveError(`@${directiveName} directive must specify a name`); } return originalName; } exports.getTableNameForModel = getTableNameForModel; //# sourceMappingURL=tableNameMap.js.map