Skip to content
This repository was archived by the owner on Mar 24, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Each entry in the `amplify` section must consist of two parts, with two optional
* `appsync` (generated code for AppSync - the format is based on the extension)
* `appClient` is the name of the Amazon Cognito user pool app client configured within the `resources` section of the `serverless.yml` file. It is optional.
* `s3bucket` is the name of the S3 Bucket used for the S3 transfer utility. It is optional. If `disabled`, no S3 bucket information is written to the configuration file. If not included, the first non-deployed S3 bucket will be used.
* `maxDepth` is the maximum level that an object needs to expand when generating statements. This only applies to `appsync` and `graphql` types.

For the `appsync` type, the extension of the file is checked. Supported formats include `flow`, `ts` (for TypeScript), `scala`, and `swift`.

Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ class ServerlessAmplifyPlugin {
* @param {Resource} resource the GraphQL API Resource
* @returns {String} path to the temporary file
*/
getTemporaryOperationsFile(resource, schemaFile) {
getTemporaryOperationsFile(resource, schemaFile, fileDetails) {
const operationsFile = path.join('.serverless', 'amplify-operations.graphql');
graphqlGenerator(schemaFile, operationsFile, { language: 'graphql' });
graphqlGenerator(schemaFile, operationsFile, { language: 'graphql', maxDepth: fileDetails.maxDepth });
return operationsFile;
}

Expand Down Expand Up @@ -542,7 +542,7 @@ class ServerlessAmplifyPlugin {
const resource = resources.find(r => r.ResourceType === 'AWS::AppSync::GraphQLApi');
if (resource) {
const schemaFile = this.getTemporarySchemaFile(resource);
graphqlGenerator(schemaFile, fileDetails.filename, { language: 'graphql' });
graphqlGenerator(schemaFile, fileDetails.filename, { language: 'graphql', maxDepth: fileDetails.maxDepth });
} else {
throw new Error(`No GraphQL API found - cannot write ${fileDetails.filename} file`);
}
Expand All @@ -558,7 +558,7 @@ class ServerlessAmplifyPlugin {
const resource = resources.find(r => r.ResourceType === 'AWS::AppSync::GraphQLApi');
if (resource) {
const schemaFile = path.resolve(this.getTemporarySchemaFile(resource));
const graphqlFile = path.resolve(this.getTemporaryOperationsFile(resource, schemaFile));
const graphqlFile = path.resolve(this.getTemporaryOperationsFile(resource, schemaFile, fileDetails));
const fileType = path.extname(fileDetails.filename).substr(1);
apiGenerator.generate(
[ graphqlFile ], /* List of GraphQL Operations */
Expand All @@ -582,7 +582,7 @@ class ServerlessAmplifyPlugin {
* @param {String} contents the contents of the file
*/
writeConfigurationFile(filename, contents) {
fs.writeFile(filename, contents, 'utf8', (err, data) => {
fs.writeFileSync(filename, contents, 'utf8', (err, data) => {
if (err) {
this.log('error', `Writing to ${filename}: ${err}`);
}
Expand Down