Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new DynamoDBModelTransformer(),
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 new CustomTransformer();
} else if (typeof CustomTransformer === 'object') {
return CustomTransformer;
}
throw new Error("Custom Transformers' default export must be a function or an object");
})
.filter(customTransformer => customTransformer);
if (customTransformers.length > 0) {
transformerList.push(...customTransformers);
}
// TODO: Build dependency mechanism into transformers. Auth runs last
// so any resolvers that need to be protected will already be created.
transformerList.push(new ModelAuthTransformer({ authConfig }));
return transformerList;
};
}
description: 'The name of the application',
required: true,
})
name: string,
@param({
description: 'The region to launch the stack in. Defaults to us-west-2',
required: false,
default: 'us-west-2'
})
region: string
) {
const transformer = new GraphQLTransform({
transformers: [
new AppSyncTransformer(),
new DynamoDBTransformer(),
new AuthTransformer()
]
})
const cfdoc = transformer.transform(schema.readSync());
const out = await createStack(cfdoc, name, region)
return 'Application creation successfully started. It may take a few minutes to finish.'
}
}
description: 'The name of the application',
required: true,
})
name: string,
@param({
description: 'The region to launch the stack in. Defaults to us-west-2',
required: false,
default: 'us-west-2'
})
region: string
) {
const transformer = new GraphQLTransform({
transformers: [
new AppSyncTransformer(),
new DynamoDBTransformer(),
new AuthTransformer()
]
})
const cfdoc = transformer.transform(schema.readSync());
const out = await updateStack(cfdoc, name, region)
return 'Application update successfully started. It may take a few minutes to finish.'
}
}
execute(schemaFile, output) {
const transformer = new graphql_transform_1.default({
transformers: [
new graphql_appsync_transformer_1.default(),
new graphql_dynamodb_transformer_1.default(),
new graphql_auth_transformer_1.default()
]
});
const cfdoc = transformer.transform(schemaFile.readSync());
output.writeSync(JSON.stringify(cfdoc, null, 4));
}
};