graphql-transformer-core
Advanced tools
Comparing version 8.2.0-rds-4.0 to 8.2.0-rds-5.0
@@ -115,2 +115,5 @@ ## API Report File for "graphql-transformer-core" | ||
// @public (undocumented) | ||
export const constructDataSourceMap: (schema: string, datasourceType: DatasourceType) => Map<string, DatasourceType>; | ||
// @public (undocumented) | ||
export interface DatasourceType { | ||
@@ -124,3 +127,3 @@ // (undocumented) | ||
// @public (undocumented) | ||
export type DBType = 'MySQL' | 'DDB'; | ||
export type DBType = 'DDB' | 'MySQL' | 'Postgres'; | ||
@@ -127,0 +130,0 @@ // Warning: (ae-forgotten-export) The symbol "ResolversFunctionsAndSchema" needs to be exported by the entry point index.d.ts |
@@ -89,3 +89,3 @@ import { Template } from 'cloudform-types'; | ||
export declare const removeAmplifyInput: (schema: string) => SchemaReaderConfig; | ||
export type DBType = 'MySQL' | 'DDB'; | ||
export type DBType = 'DDB' | 'MySQL' | 'Postgres'; | ||
export interface DatasourceType { | ||
@@ -95,3 +95,4 @@ dbType: DBType; | ||
} | ||
export declare const constructDataSourceMap: (schema: string, datasourceType: DatasourceType) => Map<string, DatasourceType>; | ||
export {}; | ||
//# sourceMappingURL=transformConfig.d.ts.map |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeAmplifyInput = exports.readSchema = exports.loadProject = exports.isDataStoreEnabled = exports.writeConfig = exports.loadConfig = exports.ConflictHandlerType = exports.TRANSFORM_CURRENT_VERSION = exports.TRANSFORM_BASE_VERSION = exports.TRANSFORM_CONFIG_FILE_NAME = void 0; | ||
exports.constructDataSourceMap = exports.removeAmplifyInput = exports.readSchema = exports.loadProject = exports.isDataStoreEnabled = exports.writeConfig = exports.loadConfig = exports.ConflictHandlerType = exports.TRANSFORM_CURRENT_VERSION = exports.TRANSFORM_BASE_VERSION = exports.TRANSFORM_CONFIG_FILE_NAME = void 0; | ||
const path = __importStar(require("path")); | ||
@@ -181,6 +181,8 @@ const lodash_1 = __importDefault(require("lodash")); | ||
for (const file of existingSchemaFiles) { | ||
const datasourceType = file.endsWith('.rds.graphql') ? constructDataSourceType('MySQL', false) : constructDataSourceType('DDB'); | ||
const fileSchema = (await fs.readFile(file)).toString(); | ||
const { amplifyType, schema: fileSchemaWithoutAmplifyInput } = (0, exports.removeAmplifyInput)(fileSchema); | ||
modelToDatasourceMap = new Map([...modelToDatasourceMap.entries(), ...constructDataSourceMap(fileSchema, datasourceType).entries()]); | ||
const datasourceType = file.endsWith('.rds.graphql') | ||
? constructDataSourceType(getRDSDBTypeFromInput(amplifyType), false) | ||
: constructDataSourceType('DDB'); | ||
modelToDatasourceMap = new Map([...modelToDatasourceMap.entries(), ...(0, exports.constructDataSourceMap)(fileSchema, datasourceType).entries()]); | ||
if (amplifyType) { | ||
@@ -200,3 +202,3 @@ amplifyInputType = mergeTypeFields(amplifyInputType, amplifyType); | ||
...modelToDatasourceMap.entries(), | ||
...constructDataSourceMap(schemaInDirectory, datasourceType).entries(), | ||
...(0, exports.constructDataSourceMap)(schemaInDirectory, datasourceType).entries(), | ||
]); | ||
@@ -214,2 +216,18 @@ schema += schemaInDirectory; | ||
exports.readSchema = readSchema; | ||
const getRDSDBTypeFromInput = (amplifyType) => { | ||
var _a; | ||
const engineInput = amplifyType.fields.find((f) => f.name.value === 'engine'); | ||
if (!engineInput) { | ||
throw new Error('engine is not defined in the RDS schema file'); | ||
} | ||
const engine = (_a = engineInput === null || engineInput === void 0 ? void 0 : engineInput.defaultValue) === null || _a === void 0 ? void 0 : _a.value; | ||
switch (engine) { | ||
case 'mysql': | ||
return 'MySQL'; | ||
case 'postgres': | ||
return 'Postgres'; | ||
default: | ||
throw new Error(`engine ${engine} specified in the RDS schema file is not supported`); | ||
} | ||
}; | ||
const removeAmplifyInput = (schema) => { | ||
@@ -267,3 +285,3 @@ const parsedSchema = (0, graphql_1.parse)(schema); | ||
} | ||
function constructDataSourceMap(schema, datasourceType) { | ||
const constructDataSourceMap = (schema, datasourceType) => { | ||
const parsedSchema = (0, graphql_1.parse)(schema); | ||
@@ -277,3 +295,4 @@ const result = new Map(); | ||
return result; | ||
} | ||
}; | ||
exports.constructDataSourceMap = constructDataSourceMap; | ||
//# sourceMappingURL=transformConfig.js.map |
{ | ||
"name": "graphql-transformer-core", | ||
"version": "8.2.0-rds-4.0", | ||
"version": "8.2.0-rds-5.0", | ||
"description": "A framework to transform from GraphQL SDL to AWS cloudFormation.", | ||
@@ -32,7 +32,7 @@ "repository": { | ||
"graphql": "^15.5.0", | ||
"graphql-transformer-common": "4.26.0-rds-4.0", | ||
"graphql-transformer-common": "4.26.0-rds-5.0", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"@aws-amplify/amplify-cli-core": "4.2.4-aug-transformer-mv-bump.0", | ||
"@aws-amplify/amplify-cli-core": "^4.2.10", | ||
"@types/fs-extra": "^8.0.1", | ||
@@ -64,3 +64,3 @@ "@types/node": "^12.12.6" | ||
}, | ||
"gitHead": "6061315de250612308d4517fe794d28a97d3a961" | ||
"gitHead": "ddbbff11d6a070cb4d2b9708c60c734a5d139bfc" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
490943
61433
4377
7
3
+ Addedgraphql-mapping-template@4.20.13-rds-5.0(transitive)
+ Addedgraphql-transformer-common@4.26.0-rds-5.0(transitive)
- Removedgraphql-mapping-template@4.20.13-rds-4.0(transitive)
- Removedgraphql-transformer-common@4.26.0-rds-4.0(transitive)