Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new ModelConnectionTransformer(),
new VersionedModelTransformer(),
new DefaultValueTransformer()
]
// Only insert certain plugins if needed, otherwise they pollute the cloudformation
// for no good reason.
// We determine if needed with a simple string search for the directive string
function conditionalInsertDirectivePlugin(plugin, searchString){
if (schema.indexOf(searchString) >= 0) {
transformers.push(plugin)
}
}
conditionalInsertDirectivePlugin(new ModelAuthTransformer(), '@auth');
conditionalInsertDirectivePlugin(new SearchableModelTransformer(), '@searchable');
// console.log(process.argv)
const transformer = new GraphQLTransform({
transformers: transformers
})
const cfdoc = transformer.transform(schema);
console.log(JSON.stringify(cfdoc, null, 2))
return async (addSearchableTransformer, storageConfig) => {
const transformerList = [
// TODO: Removing until further discussion. `getTransformerOptions(project, '@model')`
new DynamoDBModelTransformer(),
new VersionedModelTransformer(),
new FunctionTransformer(),
new HttpTransformer(),
new KeyTransformer(),
new ModelConnectionTransformer(),
new PredictionsTransformer(storageConfig),
];
if (addSearchableTransformer) {
transformerList.push(new SearchableModelTransformer());
}
const customTransformersConfig = await readTransformerConfiguration(resourceDir);
const customTransformers = (customTransformersConfig && customTransformersConfig.transformers
? customTransformersConfig.transformers
: []
)
.map(transformer => {
const fileUrlMatch = /^file:\/\/(.*)\s*$/m.exec(transformer);
const modulePath = fileUrlMatch ? fileUrlMatch[1] : transformer;
if (!modulePath) {
throw new Error(`Invalid value specified for transformer: '${transformer}'`);
}
// The loading of transformer can happen multiple ways in the following order: