UNPKG

@onn-software/ddl-to-gql

Version:

Convert a SQL DDL to a GraphQL implementation with all relations.

23 lines (22 loc) 690 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Globals = void 0; const relationTypeMap = { suffixMatch: 'suf', nameMatch: 'name', foreignKey: 'fk', }; class Globals { static getTypescriptName(tableName) { return `${Globals.TS_PREFIX}_${tableName.replaceAll('.', '__')}`; } static getGqlName(tableName) { return `${Globals.GQL_PREFIX}_${tableName}`; } static composeToRelationKey(r) { return `rel_${relationTypeMap[r.type] ?? r.type}__${r.to.table}__by__${r.from.key}__to__${r.to.key}`.replaceAll('`', ''); } } exports.Globals = Globals; Globals.TS_PREFIX = 'Onn'; Globals.GQL_PREFIX = 'Gql';