Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.ensureFileSync(graphqlSchemaFilePath);
const graphqlSchemaRaw = fs.readFileSync(graphqlSchemaFilePath, 'utf8');
const currGraphQLSchemaDoc = graphql.parse(graphqlSchemaRaw);
const rdsGraphQLSchemaDoc = graphqlSchemaContext.schemaDoc;
const concatGraphQLSchemaDoc = mergeTypes([currGraphQLSchemaDoc, rdsGraphQLSchemaDoc], { all: true });
fs.writeFileSync(graphqlSchemaFilePath, concatGraphQLSchemaDoc, 'utf8');
const resolversDir = `${projectBackendDirPath}/${category}/${resourceName}/resolvers`;
/**
* Instantiate a new Relational Template Generator and create
* the template and relational resolvers
*/
const templateGenerator = new RelationalDBTemplateGenerator(graphqlSchemaContext);
context[rdsResourceName] = resourceName;
context[rdsDatasource] = datasource;
let template = templateGenerator.createTemplate(context);
template = templateGenerator.addRelationalResolvers(template, resolversDir);
const cfn = templateGenerator.printCloudformationTemplate(template);
/**
* Add the generated the CFN to the appropriate nested stacks directory
*/
const stacksDir = `${projectBackendDirPath}/${category}/${resourceName}/stacks`;
const writeToPath = `${stacksDir}/${resourceName}-${databaseName}-rds.json`;
fs.writeFileSync(writeToPath, cfn, 'utf8');
return datasource;
})
.then(datasourceName => {