diff --git a/.codebuild/build_linux.yml b/.codebuild/build_linux.yml
index f3af95851..e55b63304 100644
--- a/.codebuild/build_linux.yml
+++ b/.codebuild/build_linux.yml
@@ -7,4 +7,4 @@ phases:
- source ./shared-scripts.sh && _buildLinux
artifacts:
files:
- - 'shared-scripts.sh'
\ No newline at end of file
+ - 'shared-scripts.sh'
diff --git a/.codebuild/cleanup_e2e_resources.yml b/.codebuild/cleanup_e2e_resources.yml
index 62394d91a..8aad9c173 100644
--- a/.codebuild/cleanup_e2e_resources.yml
+++ b/.codebuild/cleanup_e2e_resources.yml
@@ -4,7 +4,7 @@ env:
variables:
CI: true
CODEBUILD: true
-
+
phases:
build:
commands:
@@ -12,4 +12,4 @@ phases:
artifacts:
files:
- '**/*'
- base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
\ No newline at end of file
+ base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
diff --git a/.codebuild/cleanup_workflow.yml b/.codebuild/cleanup_workflow.yml
index 142aa7797..583a005fe 100644
--- a/.codebuild/cleanup_workflow.yml
+++ b/.codebuild/cleanup_workflow.yml
@@ -4,7 +4,7 @@ env:
variables:
CI: true
CODEBUILD: true
-
+
phases:
build:
commands:
@@ -13,4 +13,4 @@ phases:
artifacts:
files:
- '**/*'
- base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
\ No newline at end of file
+ base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
diff --git a/.codebuild/pr_workflow.yml b/.codebuild/pr_workflow.yml
index b75b731fd..98b69c770 100644
--- a/.codebuild/pr_workflow.yml
+++ b/.codebuild/pr_workflow.yml
@@ -39,4 +39,4 @@ batch:
env:
compute-type: BUILD_GENERAL1_MEDIUM
depend-on:
- - build_linux
\ No newline at end of file
+ - build_linux
diff --git a/.codebuild/publish_to_local_registry.yml b/.codebuild/publish_to_local_registry.yml
index b9dfe84d6..aeca3982d 100644
--- a/.codebuild/publish_to_local_registry.yml
+++ b/.codebuild/publish_to_local_registry.yml
@@ -8,4 +8,4 @@ phases:
artifacts:
files:
- - 'shared-scripts.sh'
\ No newline at end of file
+ - 'shared-scripts.sh'
diff --git a/.codebuild/run_e2e_tests.yml b/.codebuild/run_e2e_tests.yml
index 483b0243a..39b5392b1 100644
--- a/.codebuild/run_e2e_tests.yml
+++ b/.codebuild/run_e2e_tests.yml
@@ -23,4 +23,4 @@ phases:
artifacts:
files:
- '**/*'
- base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
\ No newline at end of file
+ base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
diff --git a/.codebuild/run_ios_modelgen_e2e_test.yml b/.codebuild/run_ios_modelgen_e2e_test.yml
index 3075177ad..ee07b33fc 100644
--- a/.codebuild/run_ios_modelgen_e2e_test.yml
+++ b/.codebuild/run_ios_modelgen_e2e_test.yml
@@ -29,4 +29,4 @@ phases:
artifacts:
files:
- '**/*'
- base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
\ No newline at end of file
+ base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
diff --git a/.codebuild/scripts/artifact-storage-path-allow-list-codebuild.ts b/.codebuild/scripts/artifact-storage-path-allow-list-codebuild.ts
index 608249943..54b9dd88f 100644
--- a/.codebuild/scripts/artifact-storage-path-allow-list-codebuild.ts
+++ b/.codebuild/scripts/artifact-storage-path-allow-list-codebuild.ts
@@ -28,5 +28,5 @@
*/
export const ARTIFACT_STORAGE_PATH_ALLOW_LIST_CODEBUILD = [
'$CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/',
- '$CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports'
-];
\ No newline at end of file
+ '$CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports',
+];
diff --git a/.codebuild/scripts/scan_artifacts.ts b/.codebuild/scripts/scan_artifacts.ts
index 989a978b6..d0ec408c4 100644
--- a/.codebuild/scripts/scan_artifacts.ts
+++ b/.codebuild/scripts/scan_artifacts.ts
@@ -47,4 +47,4 @@ const main = () => {
}
};
-main();
\ No newline at end of file
+main();
diff --git a/.codebuild/verify_api_extract.yml b/.codebuild/verify_api_extract.yml
index d68f393b4..ac360de6c 100644
--- a/.codebuild/verify_api_extract.yml
+++ b/.codebuild/verify_api_extract.yml
@@ -4,4 +4,4 @@ env:
phases:
build:
commands:
- - source ./shared-scripts.sh && _verifyAPIExtract
\ No newline at end of file
+ - source ./shared-scripts.sh && _verifyAPIExtract
diff --git a/.codebuild/verify_dependency_licenses_extract.yml b/.codebuild/verify_dependency_licenses_extract.yml
index 3f6712eac..8f6376b30 100644
--- a/.codebuild/verify_dependency_licenses_extract.yml
+++ b/.codebuild/verify_dependency_licenses_extract.yml
@@ -4,4 +4,4 @@ env:
phases:
build:
commands:
- - source ./shared-scripts.sh && _verifyDependencyLicensesExtract
\ No newline at end of file
+ - source ./shared-scripts.sh && _verifyDependencyLicensesExtract
diff --git a/.github/ISSUE_TEMPLATE/2.gen1_bug_report.yaml b/.github/ISSUE_TEMPLATE/2.gen1_bug_report.yaml
index 06396b09d..24b308883 100644
--- a/.github/ISSUE_TEMPLATE/2.gen1_bug_report.yaml
+++ b/.github/ISSUE_TEMPLATE/2.gen1_bug_report.yaml
@@ -1,144 +1,144 @@
name: Gen 1 Bug report
-description: Create a report to help us improve Gen 1 CLI Amplify Codegen
+description: Create a report to help us improve Gen 1 CLI Amplify Codegen
body:
-- type: markdown
- attributes:
- value: Thanks for taking the time to fill out this bug report! Try to include as much information as you can.
-- type: markdown
- attributes:
- value: For reference, the current version of the Amplify CLI is and Amplify Codegen is .
-- type: markdown
- attributes:
- value: |
- > **Note**: If your bug does not result from running `amplify codegen `, please log it in the [Amplify CLI GitHub Issue Tracker](https://github.com/aws-amplify/amplify-cli/issues).
-- type: checkboxes
- attributes:
- label: |
- Before opening, please confirm:
- options:
- - label: I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- required: true
- - label: I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+).
- required: true
- - label: I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-codegen/blob/main/CONTRIBUTING.md#bugs).
- required: true
- - label: I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- required: true
-- type: markdown
- attributes:
- value: |
- ## Environment
-- type: input
- attributes:
- label: How did you install the Amplify CLI?
- description: "For example: npm, yarn, curl, etc."
-- type: input
- attributes:
- label: If applicable, what version of Node.js are you using?
- description: You can use `node -v` to check the node version on your system.
-- type: input
- attributes:
- label: Amplify CLI Version
- placeholder: Run `amplify version` to get the Amplify CLI version
- validations:
- required: true
-- type: input
- attributes:
- label: What operating system are you using?
- description: "For example: Mac, Windows, Ubuntu."
- validations:
- required: true
-- type: markdown
- attributes:
- value: |
- ## Details
-- type: dropdown
- attributes:
- label: Amplify Codegen Command
- description: If applicable, what Amplify CLI commands (`amplify ...`) are surfacing the issue?
- multiple: true
- options:
- - codegen add
- - codegen configure
- - codegen remove
- - codegen
- - codegen statements
- - codegen types
- - codegen models
- - other `codegen ` (please mention in the issue)
- - Not applicable
- validations:
- required: true
-- type: textarea
- attributes:
- label: Describe the bug
- description: A clear and concise description of what the bug is.
- validations:
- required: true
-- type: textarea
- attributes:
- label: Expected behavior
- description: A clear and concise description of what you expected to happen.
- validations:
- required: true
-- type: textarea
- attributes:
- label: Reproduction steps
- description: |
- How do you trigger this bug? Please walk us through it step by step.
- Screenshots can be provided in the text area below.
- placeholder: |
- 1.
- 2.
- 3.
- ...
- validations:
- required: true
-- type: textarea
- attributes:
- label: GraphQL schema(s)
- description: |
- If applicable, please include your GraphQL schema(s).
+ - type: markdown
+ attributes:
+ value: Thanks for taking the time to fill out this bug report! Try to include as much information as you can.
+ - type: markdown
+ attributes:
+ value: For reference, the current version of the Amplify CLI is and Amplify Codegen is .
+ - type: markdown
+ attributes:
+ value: |
+ > **Note**: If your bug does not result from running `amplify codegen `, please log it in the [Amplify CLI GitHub Issue Tracker](https://github.com/aws-amplify/amplify-cli/issues).
+ - type: checkboxes
+ attributes:
+ label: |
+ Before opening, please confirm:
+ options:
+ - label: I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
+ required: true
+ - label: I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+).
+ required: true
+ - label: I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-codegen/blob/main/CONTRIBUTING.md#bugs).
+ required: true
+ - label: I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
+ required: true
+ - type: markdown
+ attributes:
+ value: |
+ ## Environment
+ - type: input
+ attributes:
+ label: How did you install the Amplify CLI?
+ description: 'For example: npm, yarn, curl, etc.'
+ - type: input
+ attributes:
+ label: If applicable, what version of Node.js are you using?
+ description: You can use `node -v` to check the node version on your system.
+ - type: input
+ attributes:
+ label: Amplify CLI Version
+ placeholder: Run `amplify version` to get the Amplify CLI version
+ validations:
+ required: true
+ - type: input
+ attributes:
+ label: What operating system are you using?
+ description: 'For example: Mac, Windows, Ubuntu.'
+ validations:
+ required: true
+ - type: markdown
+ attributes:
+ value: |
+ ## Details
+ - type: dropdown
+ attributes:
+ label: Amplify Codegen Command
+ description: If applicable, what Amplify CLI commands (`amplify ...`) are surfacing the issue?
+ multiple: true
+ options:
+ - codegen add
+ - codegen configure
+ - codegen remove
+ - codegen
+ - codegen statements
+ - codegen types
+ - codegen models
+ - other `codegen ` (please mention in the issue)
+ - Not applicable
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: Describe the bug
+ description: A clear and concise description of what the bug is.
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: Expected behavior
+ description: A clear and concise description of what you expected to happen.
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: Reproduction steps
+ description: |
+ How do you trigger this bug? Please walk us through it step by step.
+ Screenshots can be provided in the text area below.
+ placeholder: |
+ 1.
+ 2.
+ 3.
+ ...
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: GraphQL schema(s)
+ description: |
+ If applicable, please include your GraphQL schema(s).
- **Be sure to remove any sensitive data.**
- value: |
-
-
- ```graphql
- # Put schemas below this line
+ **Be sure to remove any sensitive data.**
+ value: |
+
+ ```graphql
+ # Put schemas below this line
- ```
-
-- type: textarea
- attributes:
- label: Log output
- description: |
- For example, error messages, or stack traces.
+ ```
- Include any relevant log output under:
-
- ```
- ~/.amplify/logs/amplify-cli-.log
- ```
+
+ - type: textarea
+ attributes:
+ label: Log output
+ description: |
+ For example, error messages, or stack traces.
- **Be sure to remove any sensitive data.**
-
- value: |
-
-
- ```
- # Put your logs below this line
+ Include any relevant log output under:
+ ```
+ ~/.amplify/logs/amplify-cli-.log
+ ```
- ```
+ **Be sure to remove any sensitive data.**
-
-- type: textarea
- attributes:
- label: Additional information
- description: |
- If you have any additional information, workarounds, etc. for us, use the field below.
- Please note, you can attach screenshots or screen recordings here, by
- dragging and dropping files in the field below.
+ value: |
+
+
+ ```
+ # Put your logs below this line
+
+
+ ```
+
+
+ - type: textarea
+ attributes:
+ label: Additional information
+ description: |
+ If you have any additional information, workarounds, etc. for us, use the field below.
+ Please note, you can attach screenshots or screen recordings here, by
+ dragging and dropping files in the field below.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index b059683b9..71d630112 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -3,28 +3,27 @@ Please make sure to read the Pull Request Guidelines:
https://github.com/aws-amplify/amplify-codegen/blob/main/CONTRIBUTING.md#pull-requests
-->
-
#### Description of changes
+
#### Codegen Paramaters Changed or Added
+
#### Issue #, if available
-
-
+
#### Description of how you validated changes
-
-
#### Checklist
+
- [ ] PR description included
@@ -36,5 +35,4 @@ List any codegen parameters changed or added.
- [ ] Changes are tested on windows. Some Node functions (such as `path`) behave differently on windows.
- [ ] Changes adhere to the [GraphQL Spec](https://spec.graphql.org/June2018/) and supports the GraphQL types `type`, `input`, `enum`, `interface`, `union` and scalar types.
-
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 17b587e9e..591cfacd0 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -1,4 +1,4 @@
-name: "CodeQL"
+name: 'CodeQL'
on:
push:
@@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- language: [ 'javascript' ]
+ language: ['javascript']
steps:
- name: Checkout
@@ -36,4 +36,4 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
- category: "/language:${{ matrix.language }}"
+ category: '/language:${{ matrix.language }}'
diff --git a/FeatureFlags.md b/FeatureFlags.md
index cff8f8d7d..ac02c364b 100644
--- a/FeatureFlags.md
+++ b/FeatureFlags.md
@@ -1,27 +1,26 @@
The implementations of `amplify-codegen` plugin and the following code generators:
+
- `appsync-modelgen-plugin` - generates model files to be used with Amplify Datastore. Accessed via CLI command `amplify codegen models`
- `graphql-docs-generator` - generates GraphQL operations from the given GraphQL schema. Accessed via CLI command `amplify codegen statements` and `amplify-codegen`
- `graphql-types-generator` - generates type definitions in given target language for the types defined in the GraphQL schema. Accessed via CLI command `amplify codegen types` and `amplify-codegen`
-are transferred to this repository from the [Amplify CLI repository](https://github.com/aws-amplify/amplify-cli/tree/master/packages).
+are transferred to this repository from the [Amplify CLI repository](https://github.com/aws-amplify/amplify-cli/tree/master/packages).
In order to shield the existing customers from any complications as a result of this transfer, we provide the following Feature Flags that enable the customers to switch to the migrated package implementations at their own pace before the deprecation date:
-1. **useAppsyncModelgenPlugin**: When set to `true`, the `appsync-modelgen-plugin` implementation in this repository will be used for models generation. When set to `false`, the `amplify-codegen-appsync-model-plugin` implementation from [CLI repo](https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-codegen-appsync-model-plugin) will be used for models generation.
+1. **useAppsyncModelgenPlugin**: When set to `true`, the `appsync-modelgen-plugin` implementation in this repository will be used for models generation. When set to `false`, the `amplify-codegen-appsync-model-plugin` implementation from [CLI repo](https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-codegen-appsync-model-plugin) will be used for models generation.
-2. **useDocsGeneratorPlugin**: When set to `true`, the `graphql-docs-generator` implementation in this repository will be used to generate the GraphQL operations. When set to `false`, the `amplify-graphql-docs-generator` implementation from [CLI repo](https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-graphql-docs-generator) will be used to generate the GraphQL operations.
+2. **useDocsGeneratorPlugin**: When set to `true`, the `graphql-docs-generator` implementation in this repository will be used to generate the GraphQL operations. When set to `false`, the `amplify-graphql-docs-generator` implementation from [CLI repo](https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-graphql-docs-generator) will be used to generate the GraphQL operations.
-3. **useTypesGeneratorPlugin**: When set to `true`, the `graphql-types-generator` implementation in this repository will be used to generate the language specific type definitions from GraphQL schema. When set to `false`, the `amplify-graphql-docs-generator` implementation from [CLI repo](https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-graphql-types-generator) will be used to generate the type defintions.
+3. **useTypesGeneratorPlugin**: When set to `true`, the `graphql-types-generator` implementation in this repository will be used to generate the language specific type definitions from GraphQL schema. When set to `false`, the `amplify-graphql-docs-generator` implementation from [CLI repo](https://github.com/aws-amplify/amplify-cli/tree/master/packages/amplify-graphql-types-generator) will be used to generate the type defintions.
-The package implementations in this repository will be actively maintained going forward while the implementations in [Amplify CLI repository](https://github.com/aws-amplify/amplify-cli/tree/master/packages) will be deprecated on May 1st, 2021.
-The package implementations in this repository will support all the APIs that are supported by their counterparts in the CLI repository.
+The package implementations in this repository will be actively maintained going forward while the implementations in [Amplify CLI repository](https://github.com/aws-amplify/amplify-cli/tree/master/packages) will be deprecated on May 1st, 2021.
+The package implementations in this repository will support all the APIs that are supported by their counterparts in the CLI repository.
These Feature Flags are set to `true` by default for new projects created using Amplify CLI and `false` for existing projects.
We recommend setting the above Feature Flags to `true` in your `cli.json` file to consume the package implementations from this repository and take advtange of bug fixes, enhancements etc being made to these generators.
-Some examples of recent enhacements include, `cleanGeneratedModelsDirectory` and `retainCaseStyle` features that are only supported when the above Feature Flags are set to true.
-Please refer to the individual package changelogs in this repository for a comprehensive list of changes.
-
-TODO: add links to amplify CLI Feature Flag docs once they are live.
-
+Some examples of recent enhacements include, `cleanGeneratedModelsDirectory` and `retainCaseStyle` features that are only supported when the above Feature Flags are set to true.
+Please refer to the individual package changelogs in this repository for a comprehensive list of changes.
+TODO: add links to amplify CLI Feature Flag docs once they are live.
diff --git a/README-relationships.md b/README-relationships.md
index 100e1acbe..a074a2b28 100644
--- a/README-relationships.md
+++ b/README-relationships.md
@@ -65,7 +65,7 @@ the MIS (abridged to show relationship information only) looks like:
"attributes": [],
"association": {
"connectionType": "HAS_ONE",
- "associatedWith": ["primaryId"],
+ "associatedWith": ["primaryId"]
}
}
}
@@ -126,16 +126,16 @@ the MIS (abridged to show relationship information only) looks like:
## Glossary
-* **Associated type** - In a field decorated with a `@hasMany`, `@hasOne`, or `@belongsTo` directive, the model “pointed to” by the directive. In the sample schema:
- * `Related` is the **associated type** for the `@hasMany` directive on `Primary.related`
- * `Primary` is the **associated type** for the `@belongsTo` directive on `Related.primary`
-* **Association field** - See **Connection field**
-* **Connection field** - In any model type, the field that is decorated with a `@hasMany`, `@hasOne`, or `@belongsTo` directive. In the sample schema:
- * `Primary.related` is the **connection field** in the `Primary` model, for the relationship `Primary -> Related` defined by the `@hasMany` on `Primary.related` and the `@belongsTo` on `Related.primary`
- * `Related.primary` is the **connection field** in the `Related` model, for the relationship `Primary -> Related` defined by the `@hasMany` on `Primary.related` and the `@belongsTo` on `Related.primary`
-* **Source type** - In a field decorated with a `@hasMany`, `@hasOne`, or `@belongsTo` directive, the model containing the directive. In the sample schema:
- * `Primary` is the **source type** for the `@hasMany` directive on `Primary.related`
- * `Related` is the **source type** for the `@belongsTo` directive on `Related.primary`
+- **Associated type** - In a field decorated with a `@hasMany`, `@hasOne`, or `@belongsTo` directive, the model “pointed to” by the directive. In the sample schema:
+ - `Related` is the **associated type** for the `@hasMany` directive on `Primary.related`
+ - `Primary` is the **associated type** for the `@belongsTo` directive on `Related.primary`
+- **Association field** - See **Connection field**
+- **Connection field** - In any model type, the field that is decorated with a `@hasMany`, `@hasOne`, or `@belongsTo` directive. In the sample schema:
+ - `Primary.related` is the **connection field** in the `Primary` model, for the relationship `Primary -> Related` defined by the `@hasMany` on `Primary.related` and the `@belongsTo` on `Related.primary`
+ - `Related.primary` is the **connection field** in the `Related` model, for the relationship `Primary -> Related` defined by the `@hasMany` on `Primary.related` and the `@belongsTo` on `Related.primary`
+- **Source type** - In a field decorated with a `@hasMany`, `@hasOne`, or `@belongsTo` directive, the model containing the directive. In the sample schema:
+ - `Primary` is the **source type** for the `@hasMany` directive on `Primary.related`
+ - `Related` is the **source type** for the `@belongsTo` directive on `Related.primary`
## Structure
@@ -153,26 +153,26 @@ enum CodeGenConnectionType {
type CodeGenConnectionTypeBase = {
kind: CodeGenConnectionType;
connectedModel: CodeGenModel;
- // ^-- Type not shown
+ // ^-- Type not shown
};
type CodeGenFieldConnectionBelongsTo = CodeGenConnectionTypeBase & {
kind: CodeGenConnectionType.BELONGS_TO;
targetNames: string[];
-}
+};
type CodeGenFieldConnectionHasOne = CodeGenConnectionTypeBase & {
kind: CodeGenConnectionType.HAS_ONE;
associatedWith: CodeGenField[];
- // ^-- Type not shown -- rendered in MIS as a string array
+ // ^-- Type not shown -- rendered in MIS as a string array
targetNames: string[];
-}
+};
export type CodeGenFieldConnectionHasMany = CodeGenConnectionTypeBase & {
kind: CodeGenConnectionType.HAS_MANY;
associatedWith: CodeGenField[];
- // ^-- Type not shown -- rendered in MIS as a string array
-}
+ // ^-- Type not shown -- rendered in MIS as a string array
+};
```
Considering a snippet of the above sample:
@@ -232,31 +232,27 @@ Considering a snippet of the above sample:
- `models.RelatedMany.fields.primary.association.targetNames` - A list of fields on the **source type** (that is, the current type) that hold the primary key of the **associated** record. This is an array so we can support composite primary keys.
- `models.RelatedMany.fields.primaryId` - The field pointed to by `targetNames` above, containing the primary key of the **associated** record for the `RelatedOne.primary` relationship.
-
## Navigating relationships
We will describe the steps to resolve the record in pseudo-sql
### From source record to associated record
-* If the source model has an `associatedWith` but no `targetNames`:
- ```
- SELECT *
- FROM
- WHERE = .primaryKey
- ```
-* If the source model has an `associatedWith` AND `targetNames`:
- ```
- SELECT *
- FROM
- WHERE = .
- ```
-* If the source model has a `targetNames` but no `associatedWith`:
- ```
- SELECT *
- FROM
- WHERE . = .primaryKey
- ```
-
-
-
+- If the source model has an `associatedWith` but no `targetNames`:
+ ```
+ SELECT *
+ FROM
+ WHERE = .primaryKey
+ ```
+- If the source model has an `associatedWith` AND `targetNames`:
+ ```
+ SELECT *
+ FROM
+ WHERE = .
+ ```
+- If the source model has a `targetNames` but no `associatedWith`:
+ ```
+ SELECT *
+ FROM
+ WHERE . = .primaryKey
+ ```
diff --git a/Readme.md b/Readme.md
index 1cb9118b2..9c3675c3f 100644
--- a/Readme.md
+++ b/Readme.md
@@ -12,19 +12,22 @@
### Reporting Bugs/Feature Requests
+
[![Open Bugs](https://img.shields.io/github/issues/aws-amplify/amplify-codegen/bug?color=d73a4a&label=bugs)](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
[![Feature Requests](https://img.shields.io/github/issues/aws-amplify/amplify-codegen/feature-request?color=ff9001&label=feature%20requests)](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+label%3Afeature-request+is%3Aopen)
[![Enhancements](https://img.shields.io/github/issues/aws-amplify/amplify-codegen/enhancement?color=4287f5&label=enhancement)](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement)
[![Closed Issues](https://img.shields.io/github/issues-closed/aws-amplify/amplify-codegen?color=%2325CC00&label=issues%20closed)](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+is%3Aclosed+)
# Amplify Codegen
+
Amplify Codegen is a JavaScript toolkit library for frontend and mobile developers building amplify applications. Packages are mainly used for frontend code generation including:
-| Package | Description |
+| Package | Description |
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| amplify-codegen | Amplify plugin for code generation |
-| appsync-modelgen-plugin | Model generator for Amplify Datastore |
-| graphql-docs-generator | Generates statements from GraphQL schema |
-| graphql-types-generator | Generates type annotations from GraphQL schema and statements |
+| amplify-codegen | Amplify plugin for code generation |
+| appsync-modelgen-plugin | Model generator for Amplify Datastore |
+| graphql-docs-generator | Generates statements from GraphQL schema |
+| graphql-types-generator | Generates type annotations from GraphQL schema and statements |
+
## Developing
This section should get you running with **Amplify Codegen**. You will need to set [nodejs](https://nodejs.org/en/) to a version less than v16 on your system. Developing locally also requires [yarn](https://classic.yarnpkg.com/en/docs/install#mac-stable).
@@ -47,6 +50,7 @@ Before pushing code or sending a pull request, do the following:
- If there are any remaining lint errors, resolve them manually. Linting your code is a best practice that ensures good code quality so it's important that you don't skip this step.
## Troubleshooting
+
Errors sometimes occur when a different version of `amplify-cli-core` is installed, typically during the time the CLI is updated. To resolve the error, execute the following command from the top-level directory:
`rm -rf yarn.lock && yarn clean && yarn setup-dev`
diff --git a/jest.config.js b/jest.config.js
index 117297c2f..7decf0b2d 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -4,11 +4,7 @@ module.exports = {
verbose: true,
testRunner: 'jest-circus/runner',
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
- testPathIgnorePatterns: [
- '**/*.d.ts',
- '**/__e2e__/',
- '**/__integration__/'
- ],
+ testPathIgnorePatterns: ['**/*.d.ts', '**/__e2e__/', '**/__integration__/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'core', 'node'],
collectCoverage: true,
collectCoverageFrom: ['src/**/.(ts|tsx|js|jsx)$', '!src/**/*.test.(ts|tsx|js|jsx)$', '!src/**/*.d.ts'],
@@ -16,6 +12,6 @@ module.exports = {
projects: [
'/packages/appsync-modelgen-plugin',
'/packages/graphql-docs-generator',
- '/packages/graphql-types-generator'
+ '/packages/graphql-types-generator',
],
};
diff --git a/packages/amplify-codegen-e2e-core/Readme.md b/packages/amplify-codegen-e2e-core/Readme.md
index 1f2538448..d99f09bb4 100644
--- a/packages/amplify-codegen-e2e-core/Readme.md
+++ b/packages/amplify-codegen-e2e-core/Readme.md
@@ -1,3 +1,3 @@
# Amplify Codegen E2E core
-This package contains the code shared between end to end test packages.
\ No newline at end of file
+This package contains the code shared between end to end test packages.
diff --git a/packages/amplify-codegen-e2e-core/src/categories/api.ts b/packages/amplify-codegen-e2e-core/src/categories/api.ts
index f510115d5..db16d396d 100644
--- a/packages/amplify-codegen-e2e-core/src/categories/api.ts
+++ b/packages/amplify-codegen-e2e-core/src/categories/api.ts
@@ -486,7 +486,7 @@ export function addApi(projectDir: string, settings?: any) {
chain.wait('Configure additional auth types?').sendConfirmYes();
- authTypesToSelectFrom = authTypesToSelectFrom.filter(x => x !== defaultType);
+ authTypesToSelectFrom = authTypesToSelectFrom.filter((x) => x !== defaultType);
multiSelect(
chain.wait('Choose the additional authorization types you want to configure for the API'),
@@ -494,7 +494,7 @@ export function addApi(projectDir: string, settings?: any) {
authTypesToSelectFrom,
);
- authTypesToAdd.forEach(authType => {
+ authTypesToAdd.forEach((authType) => {
setupAuthType(authType, chain, settings);
});
} else {
@@ -648,7 +648,7 @@ export function rebuildApi(projDir: string, apiName: string) {
.wait('Type the name of the API to confirm you want to continue')
.sendLine(apiName)
.wait('All resources are updated in the cloud')
- .run(err => (err ? reject(err) : resolve()));
+ .run((err) => (err ? reject(err) : resolve()));
});
}
diff --git a/packages/amplify-codegen-e2e-core/src/categories/auth.ts b/packages/amplify-codegen-e2e-core/src/categories/auth.ts
index 217d645f4..c714155d4 100644
--- a/packages/amplify-codegen-e2e-core/src/categories/auth.ts
+++ b/packages/amplify-codegen-e2e-core/src/categories/auth.ts
@@ -455,14 +455,8 @@ export function addAuthWithSignInSignOutUrl(cwd: string, settings: any): Promise
export function addAuthWithDefaultSocial(cwd: string, settings: any): Promise {
return new Promise((resolve, reject) => {
- const {
- FACEBOOK_APP_ID,
- FACEBOOK_APP_SECRET,
- GOOGLE_APP_ID,
- GOOGLE_APP_SECRET,
- AMAZON_APP_ID,
- AMAZON_APP_SECRET,
- }: any = getSocialProviders(true);
+ const { FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, GOOGLE_APP_ID, GOOGLE_APP_SECRET, AMAZON_APP_ID, AMAZON_APP_SECRET }: any =
+ getSocialProviders(true);
spawn(getCLIPath(), ['add', 'auth'], { cwd, stripColors: true })
.wait('Do you want to use the default authentication and security configuration?')
diff --git a/packages/amplify-codegen-e2e-core/src/categories/codegen.ts b/packages/amplify-codegen-e2e-core/src/categories/codegen.ts
index 82582441c..a4d83bda9 100644
--- a/packages/amplify-codegen-e2e-core/src/categories/codegen.ts
+++ b/packages/amplify-codegen-e2e-core/src/categories/codegen.ts
@@ -3,7 +3,7 @@ import { getCLIPath, nspawn as spawn } from '..';
export function generateModels(cwd: string, outputDir?: string, settings: { errMessage?: string } = {}): Promise {
return new Promise((resolve, reject) => {
- const params = ['codegen', 'models', ...(outputDir ? ['--output-dir', outputDir] : [])]
+ const params = ['codegen', 'models', ...(outputDir ? ['--output-dir', outputDir] : [])];
const chain = spawn(getCLIPath(), params, { cwd, stripColors: true });
if (settings?.errMessage) {
@@ -20,19 +20,20 @@ export function generateModels(cwd: string, outputDir?: string, settings: { errM
});
}
-export const generateModelsWithOptions = (cwd: string, options: Record): Promise => new Promise((resolve, reject) => {
- spawn(getCLIPath(), ['codegen', 'models', ...(Object.entries(options).flat())], { cwd, stripColors: true }).run((err: Error) => {
- if (!err) {
- resolve();
- } else {
- reject(err);
- }
+export const generateModelsWithOptions = (cwd: string, options: Record): Promise =>
+ new Promise((resolve, reject) => {
+ spawn(getCLIPath(), ['codegen', 'models', ...Object.entries(options).flat()], { cwd, stripColors: true }).run((err: Error) => {
+ if (!err) {
+ resolve();
+ } else {
+ reject(err);
+ }
+ });
});
-});
-export function generateStatementsAndTypes(cwd: string, errorMessage?: string) : Promise {
+export function generateStatementsAndTypes(cwd: string, errorMessage?: string): Promise {
return new Promise((resolve, reject) => {
- const chain = spawn(getCLIPath(), ['codegen'], { cwd, stripColors: true })
+ const chain = spawn(getCLIPath(), ['codegen'], { cwd, stripColors: true });
if (errorMessage) {
chain.wait(errorMessage);
@@ -44,33 +45,31 @@ export function generateStatementsAndTypes(cwd: string, errorMessage?: string) :
} else {
reject(err);
}
- })
+ });
});
}
-export function generateStatements(cwd: string) : Promise {
+export function generateStatements(cwd: string): Promise {
return new Promise((resolve, reject) => {
- spawn(getCLIPath(), ['codegen', 'statements'], { cwd, stripColors: true })
- .run((err: Error) => {
+ spawn(getCLIPath(), ['codegen', 'statements'], { cwd, stripColors: true }).run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
- })
+ });
});
}
-export function generateTypes(cwd: string) : Promise {
+export function generateTypes(cwd: string): Promise {
return new Promise((resolve, reject) => {
- spawn(getCLIPath(), ['codegen', 'types'], { cwd, stripColors: true })
- .run((err: Error) => {
+ spawn(getCLIPath(), ['codegen', 'types'], { cwd, stripColors: true }).run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
- })
+ });
});
}
@@ -88,24 +87,19 @@ export function addCodegen(cwd: string, settings: any = {}): Promise {
maxDepth: '\r', // default value
isTypeGenerated: true,
typeFileName: '\r', // default value
- }
+ };
const mergedSettings = { ...defaultSettings, ...settings };
return new Promise((resolve, reject) => {
- const params = mergedSettings.params
- ? ['codegen', 'add', ...mergedSettings.params]
- : ['codegen', 'add'];
+ const params = mergedSettings.params ? ['codegen', 'add', ...mergedSettings.params] : ['codegen', 'add'];
const chain = spawn(getCLIPath(), params, { cwd, stripColors: true });
- if(mergedSettings.frontendType === AmplifyFrontend.flutter) {
- chain.wait("Flutter only supports the command $amplify codegen models. All the other codegen commands are not supported.");
- }
- else if (mergedSettings.isAPINotAdded) {
- chain.wait("There are no GraphQL APIs available.");
- chain.wait("Add by running $amplify api add");
- }
- else if (mergedSettings.isCodegenAdded) {
- chain.wait("Codegen support only one GraphQL API per project");
- }
- else {
+ if (mergedSettings.frontendType === AmplifyFrontend.flutter) {
+ chain.wait('Flutter only supports the command $amplify codegen models. All the other codegen commands are not supported.');
+ } else if (mergedSettings.isAPINotAdded) {
+ chain.wait('There are no GraphQL APIs available.');
+ chain.wait('Add by running $amplify api add');
+ } else if (mergedSettings.isCodegenAdded) {
+ chain.wait('Codegen support only one GraphQL API per project');
+ } else {
if (mergedSettings.frontendType === AmplifyFrontend.javascript) {
chain.wait('Choose the code generation language target');
if (mergedSettings.framework === 'angular' || mergedSettings.framework === 'ionic') {
@@ -127,18 +121,19 @@ export function addCodegen(cwd: string, settings: any = {}): Promise {
chain.sendLine('n');
}
- const isTypeGenIncluded = mergedSettings.frontendType === AmplifyFrontend.ios
- || (mergedSettings.frontendType === AmplifyFrontend.javascript && mergedSettings.codegenTarget !== 'javascript');
+ const isTypeGenIncluded =
+ mergedSettings.frontendType === AmplifyFrontend.ios ||
+ (mergedSettings.frontendType === AmplifyFrontend.javascript && mergedSettings.codegenTarget !== 'javascript');
if (isTypeGenIncluded) {
chain
.wait('Enter the file name for the generated code')
.sendLine(mergedSettings.typeFileName)
.wait('Do you want to generate code for your newly created GraphQL API');
- if (mergedSettings.isTypeGenerated) {
- chain.sendLine('y');
- } else {
- chain.sendLine('n');
- }
+ if (mergedSettings.isTypeGenerated) {
+ chain.sendLine('y');
+ } else {
+ chain.sendLine('n');
+ }
}
}
@@ -157,7 +152,7 @@ export function removeCodegen(cwd: string, isCodegenAdded: boolean = true): Prom
return new Promise((resolve, reject) => {
const chain = spawn(getCLIPath(), ['codegen', 'remove'], { cwd, stripColors: true });
if (!isCodegenAdded) {
- chain.wait("Codegen is not configured");
+ chain.wait('Codegen is not configured');
}
chain.run((err: Error) => {
if (!err) {
@@ -176,23 +171,15 @@ export function configureCodegen(cwd: string, settings: any = {}): Promise
if (settings.frontendType === AmplifyFrontend.javascript) {
chain.wait('Choose the code generation language target').sendCarriageReturn();
}
- chain
- .wait('Enter the file name pattern of graphql queries, mutations and subscriptions')
- .sendCarriageReturn()
+ chain.wait('Enter the file name pattern of graphql queries, mutations and subscriptions').sendCarriageReturn();
if (!settings.isCodegenConfigured) {
- chain
- .wait('Do you want to generate/update all possible GraphQL operations')
- .sendLine('y')
- }
- else if (settings.frontendType === AmplifyFrontend.ios) {
- chain
- .wait('Enter the file name for the generated code')
- .sendCarriageReturn()
+ chain.wait('Do you want to generate/update all possible GraphQL operations').sendLine('y');
+ } else if (settings.frontendType === AmplifyFrontend.ios) {
+ chain.wait('Enter the file name for the generated code').sendCarriageReturn();
}
- chain
- .wait('Enter maximum statement depth [increase from default if your schema is deeply')
+ chain.wait('Enter maximum statement depth [increase from default if your schema is deeply');
settings.maxStatementDepth ? chain.sendLine(settings.maxStatementDepth) : chain.sendCarriageReturn();
if (settings.frontendType === AmplifyFrontend.ios && !settings.isCodegenConfigured) {
@@ -204,7 +191,7 @@ export function configureCodegen(cwd: string, settings: any = {}): Promise
}
if (settings.isCodegenConfigured) {
- chain.wait("Codegen configured. Remember to run \"amplify codegen\" to generate your types and statements.");
+ chain.wait('Codegen configured. Remember to run "amplify codegen" to generate your types and statements.');
}
chain.run((err: Error) => {
@@ -217,9 +204,12 @@ export function configureCodegen(cwd: string, settings: any = {}): Promise
});
}
-export function generateModelIntrospection(cwd: string, settings: { outputDir?: string, errMessage?: string} = {}): Promise {
+export function generateModelIntrospection(cwd: string, settings: { outputDir?: string; errMessage?: string } = {}): Promise {
return new Promise((resolve, reject) => {
- const chain = spawn(getCLIPath(), ['codegen', 'model-introspection', '--output-dir', settings.outputDir ?? ''], { cwd, stripColors: true });
+ const chain = spawn(getCLIPath(), ['codegen', 'model-introspection', '--output-dir', settings.outputDir ?? ''], {
+ cwd,
+ stripColors: true,
+ });
if (settings?.errMessage) {
chain.wait(settings.errMessage);
}
@@ -239,14 +229,15 @@ export function addCodegenNonAmplifyJS(cwd: string, params: Array, initi
const chain = spawn(getCLIPath(), ['codegen', 'add', ...params], { cwd, stripColors: true });
if (initialFailureMessage) {
- chain.wait(initialFailureMessage)
+ chain.wait(initialFailureMessage);
} else {
chain
.wait("Choose the type of app that you're building")
.sendCarriageReturn()
.wait('What javascript framework are you using')
.sendCarriageReturn()
- .wait('Choose the code generation language target').sendCarriageReturn()
+ .wait('Choose the code generation language target')
+ .sendCarriageReturn()
.wait('Enter the file name pattern of graphql queries, mutations and subscriptions')
.sendCarriageReturn()
.wait('Do you want to generate/update all possible GraphQL operations')
@@ -270,17 +261,26 @@ export function addCodegenNonAmplifyTS(cwd: string, params: Array, initi
const chain = spawn(getCLIPath(), ['codegen', 'add', ...params], { cwd, stripColors: true });
if (initialFailureMessage) {
- chain.wait(initialFailureMessage)
+ chain.wait(initialFailureMessage);
} else {
chain
- .wait("Choose the type of app that you're building").sendCarriageReturn()
- .wait('What javascript framework are you using').sendCarriageReturn()
- .wait('Choose the code generation language target').sendKeyDown().sendCarriageReturn()
- .wait('Enter the file name pattern of graphql queries, mutations and subscriptions').sendCarriageReturn()
- .wait('Do you want to generate/update all possible GraphQL operations').sendLine('y')
- .wait('Enter maximum statement depth [increase from default if your schema is deeply').sendCarriageReturn()
- .wait('Enter the file name for the generated code').sendCarriageReturn()
- .wait('Do you want to generate code for your newly created GraphQL API').sendCarriageReturn();
+ .wait("Choose the type of app that you're building")
+ .sendCarriageReturn()
+ .wait('What javascript framework are you using')
+ .sendCarriageReturn()
+ .wait('Choose the code generation language target')
+ .sendKeyDown()
+ .sendCarriageReturn()
+ .wait('Enter the file name pattern of graphql queries, mutations and subscriptions')
+ .sendCarriageReturn()
+ .wait('Do you want to generate/update all possible GraphQL operations')
+ .sendLine('y')
+ .wait('Enter maximum statement depth [increase from default if your schema is deeply')
+ .sendCarriageReturn()
+ .wait('Enter the file name for the generated code')
+ .sendCarriageReturn()
+ .wait('Do you want to generate code for your newly created GraphQL API')
+ .sendCarriageReturn();
}
chain.run((err: Error) => {
@@ -291,4 +291,4 @@ export function addCodegenNonAmplifyTS(cwd: string, params: Array, initi
}
});
});
-}
\ No newline at end of file
+}
diff --git a/packages/amplify-codegen-e2e-core/src/categories/lambda-function.ts b/packages/amplify-codegen-e2e-core/src/categories/lambda-function.ts
index 21d92faa0..463146242 100644
--- a/packages/amplify-codegen-e2e-core/src/categories/lambda-function.ts
+++ b/packages/amplify-codegen-e2e-core/src/categories/lambda-function.ts
@@ -55,7 +55,7 @@ const additionalPermissions = (cwd: string, chain: ExecutionContext, settings: a
}
// n-resources repeated questions
- settings.additionalPermissions.resources.forEach(elem => {
+ settings.additionalPermissions.resources.forEach((elem) => {
const service = _.get(getBackendAmplifyMeta(cwd), ['api', elem, 'service']);
const gqlpermff = !!_.get(loadFeatureFlags(cwd), ['features', 'appsync', 'generategraphqlpermissions']);
const isAppSyncApi = service === 'AppSync';
@@ -292,12 +292,12 @@ const addLayerWalkthrough = (chain: ExecutionContext, options: LayerOptions) =>
}
chain.wait('Provide existing layers');
multiSelect(chain, amendedSelection, prependedListOptions);
- options.select.forEach(selection => {
+ options.select.forEach((selection) => {
chain.wait(`Select a version for ${selection}`);
singleSelect(
chain,
options.versions[selection].version.toString(),
- options.versions[selection].expectedVersionOptions.map(op => op.toString()),
+ options.versions[selection].expectedVersionOptions.map((op) => op.toString()),
);
});
if (hasCustomArns) {
@@ -410,7 +410,7 @@ export const functionMockAssert = (
.wait(settings.successString)
.wait('Finished execution.')
.sendEof()
- .run(err => (err ? reject(err) : resolve()));
+ .run((err) => (err ? reject(err) : resolve()));
});
};
diff --git a/packages/amplify-codegen-e2e-core/src/categories/lambda-layer.ts b/packages/amplify-codegen-e2e-core/src/categories/lambda-layer.ts
index 69d1d26c1..74aa0dafa 100644
--- a/packages/amplify-codegen-e2e-core/src/categories/lambda-layer.ts
+++ b/packages/amplify-codegen-e2e-core/src/categories/lambda-layer.ts
@@ -33,21 +33,21 @@ export function validatePushedVersion(
) {
const layerData = getLayerDataFromTeamProviderInfo(projRoot, layerName, envName);
const storedPermissions: LayerPermission[] = _.get(layerData, ['layerVersionMap', `${version}`, 'permissions']);
- permissions.forEach(perm => expect(storedPermissions).toContainEqual(perm));
+ permissions.forEach((perm) => expect(storedPermissions).toContainEqual(perm));
}
export async function validateLayerMetadata(projRoot: string, layerName: string, meta: any, envName: string) {
const { Arn: arn, Region: region } = meta.function[layerName].output;
const localLayerData = getLayerDataFromTeamProviderInfo(projRoot, layerName, envName);
const runtimes = getLayerRuntimes(projRoot, layerName);
- const runtimeValues = Object.keys(runtimes).map(key => runtimes[key].cloudTemplateValue);
+ const runtimeValues = Object.keys(runtimes).map((key) => runtimes[key].cloudTemplateValue);
const localVersions = Object.keys(localLayerData.layerVersionMap);
expect(arn).toBeDefined();
expect(region).toBeDefined();
const cloudData = await getLayerVersion(arn, region);
const { LayerVersions: Versions } = await listVersions(`${layerName}-${envName}`, region);
- const cloudVersions = Versions.map(version => version.Version);
+ const cloudVersions = Versions.map((version) => version.Version);
expect(cloudVersions.map(String).sort()).toEqual(localVersions.sort());
expect(cloudData.LayerVersionArn).toEqual(arn);
expect(cloudData.CompatibleRuntimes).toEqual(runtimeValues);
@@ -172,7 +172,7 @@ function getLayerRuntimes(projRoot: string, layerName: string) {
}
function getRuntimeDisplayNames(runtimes: LayerRuntimes[]) {
- return runtimes.map(runtime => getLayerRuntimeInfo(runtime).displayName);
+ return runtimes.map((runtime) => getLayerRuntimeInfo(runtime).displayName);
}
function getLayerRuntimeInfo(runtime: LayerRuntimes) {
diff --git a/packages/amplify-codegen-e2e-core/src/cli-test-environment.js b/packages/amplify-codegen-e2e-core/src/cli-test-environment.js
index a145c126d..014dda150 100644
--- a/packages/amplify-codegen-e2e-core/src/cli-test-environment.js
+++ b/packages/amplify-codegen-e2e-core/src/cli-test-environment.js
@@ -20,7 +20,7 @@ class CLIEnvironment extends NodeEnvironment {
async setup() {
await super.setup();
- this.global.storeCLIExecutionLog = result => {
+ this.global.storeCLIExecutionLog = (result) => {
this.currentBlock.logs.push(result);
};
@@ -30,7 +30,7 @@ class CLIEnvironment extends NodeEnvironment {
};
this.global.getDescibeBlocks = () => {
- return this.describeBlocks.filter(b => b !== 'ROOT_DESCRIBE_BLOCK');
+ return this.describeBlocks.filter((b) => b !== 'ROOT_DESCRIBE_BLOCK');
};
this.global.getHookName = () => {
@@ -40,7 +40,7 @@ class CLIEnvironment extends NodeEnvironment {
async teardown() {
if (this.context.global.addCLITestRunnerLogs) {
- const result = this.cliExecutionLogs.children.find(log => log.type === 'describe' && log.name === 'ROOT_DESCRIBE_BLOCK');
+ const result = this.cliExecutionLogs.children.find((log) => log.type === 'describe' && log.name === 'ROOT_DESCRIBE_BLOCK');
if (result) {
this.context.global.addCLITestRunnerLogs(result);
}
diff --git a/packages/amplify-codegen-e2e-core/src/cli-test-runner.js b/packages/amplify-codegen-e2e-core/src/cli-test-runner.js
index ad6255698..46cc58eee 100644
--- a/packages/amplify-codegen-e2e-core/src/cli-test-runner.js
+++ b/packages/amplify-codegen-e2e-core/src/cli-test-runner.js
@@ -5,7 +5,7 @@ const uuid = require('uuid');
const mutex = throat(1);
export const run = async (globalConfig, config, environment, runtime, testPath) => {
const CLITestRunner = {};
- environment.global.addCLITestRunnerLogs = logs => {
+ environment.global.addCLITestRunnerLogs = (logs) => {
CLITestRunner.logs = logs;
};
diff --git a/packages/amplify-codegen-e2e-core/src/configure/index.ts b/packages/amplify-codegen-e2e-core/src/configure/index.ts
index 347af7b96..20cf441ce 100644
--- a/packages/amplify-codegen-e2e-core/src/configure/index.ts
+++ b/packages/amplify-codegen-e2e-core/src/configure/index.ts
@@ -31,7 +31,7 @@ export const amplifyRegions = [
'us-west-1',
'us-west-2',
'eu-north-1',
- "eu-south-1",
+ 'eu-south-1',
'eu-west-1',
'eu-west-2',
'eu-west-3',
@@ -49,8 +49,7 @@ export const amplifyRegions = [
const configurationOptions = ['Project information', 'AWS Profile setting', 'Advanced: Container-based deployments'];
const profileOptions = ['No', 'Update AWS Profile', 'Remove AWS Profile'];
const authenticationOptions = ['AWS profile', 'AWS access keys'];
-const javaScriptFrameworkList = [ 'none', 'angular', 'ember', 'ionic', 'react', 'react-native', 'vue' ];
-
+const javaScriptFrameworkList = ['none', 'angular', 'ember', 'ionic', 'react', 'react-native', 'vue'];
const MANDATORY_PARAMS = ['accessKeyId', 'secretAccessKey', 'region'];
@@ -142,13 +141,8 @@ export function amplifyConfigureProject(settings: {
});
}
-export function amplifyConfigureProjectInfo(settings: {
- cwd: string,
- frontendType: string,
-}): Promise {
- const {
- cwd,
- } = settings;
+export function amplifyConfigureProjectInfo(settings: { cwd: string; frontendType: string }): Promise {
+ const { cwd } = settings;
const s = { ...defaultProjectSettings, ...settings };
return new Promise((resolve, reject) => {
const chain = spawn(getCLIPath(), ['configure', 'project'], { cwd, stripColors: true }).wait('Which setting do you want to configure?');
@@ -176,29 +170,23 @@ export function amplifyConfigureProjectInfo(settings: {
.sendLine(s.startCmd);
break;
case 'android':
- chain
- .wait('Where is your Res directory')
- .sendLine(s.srcDir);
+ chain.wait('Where is your Res directory').sendLine(s.srcDir);
break;
case 'ios':
break;
case 'flutter':
- chain
- .wait('Where do you want to store your configuration file?')
- .sendLine(s.srcDir);
+ chain.wait('Where do you want to store your configuration file?').sendLine(s.srcDir);
break;
default:
throw new Error(`Frontend type ${s.frontendType} is not supported.`);
}
- chain
- .wait('Successfully made configuration changes to your project.')
- .run((err: Error) => {
- if (!err) {
- resolve();
- } else {
- reject(err);
- }
- });
- })
-}
\ No newline at end of file
+ chain.wait('Successfully made configuration changes to your project.').run((err: Error) => {
+ if (!err) {
+ resolve();
+ } else {
+ reject(err);
+ }
+ });
+ });
+}
diff --git a/packages/amplify-codegen-e2e-core/src/index.ts b/packages/amplify-codegen-e2e-core/src/index.ts
index cf76bd643..1196a4b97 100644
--- a/packages/amplify-codegen-e2e-core/src/index.ts
+++ b/packages/amplify-codegen-e2e-core/src/index.ts
@@ -69,9 +69,7 @@ export async function createNewProjectDir(
projectName: string,
prefix = path.join(fs.realpathSync(os.tmpdir()), amplifyTestsDir),
): Promise {
- const currentHash = execSync('git rev-parse --short HEAD', { cwd: __dirname })
- .toString()
- .trim();
+ const currentHash = execSync('git rev-parse --short HEAD', { cwd: __dirname }).toString().trim();
let projectDir;
do {
const randomId = await global.getRandomId();
diff --git a/packages/amplify-codegen-e2e-core/src/init/amplifyPull.ts b/packages/amplify-codegen-e2e-core/src/init/amplifyPull.ts
index 834db65e5..5734de72a 100644
--- a/packages/amplify-codegen-e2e-core/src/init/amplifyPull.ts
+++ b/packages/amplify-codegen-e2e-core/src/init/amplifyPull.ts
@@ -8,7 +8,7 @@ export function amplifyPull(
emptyDir?: boolean;
appId?: string;
withRestore?: boolean;
- frontendConfig?: AmplifyFrontendConfig
+ frontendConfig?: AmplifyFrontendConfig;
},
): Promise {
if (!settings.frontendConfig) {
@@ -36,9 +36,7 @@ export function amplifyPull(
.wait('Choose your default editor:')
.sendCarriageReturn();
initializeFrontend(chain, settings.frontendConfig);
- chain
- .wait('Do you plan on modifying this backend?')
- .sendLine('y');
+ chain.wait('Do you plan on modifying this backend?').sendLine('y');
} else {
chain.wait('Pre-pull status').wait('Current Environment');
}
@@ -68,69 +66,48 @@ export function amplifyPull(
});
}
-export function amplifyPullSandbox(cwd: string, settings: { sandboxId: string; appType: AmplifyFrontend; }) {
+export function amplifyPullSandbox(cwd: string, settings: { sandboxId: string; appType: AmplifyFrontend }) {
return new Promise((resolve, reject) => {
const args = ['pull', '--sandboxId', settings.sandboxId];
- const chain = spawn(getCLIPath(), args, { cwd, stripColors: true })
- .wait('What type of app are you building');
+ const chain = spawn(getCLIPath(), args, { cwd, stripColors: true }).wait('What type of app are you building');
switch (settings.appType) {
case AmplifyFrontend.javascript:
- chain
- .sendCarriageReturn()
- .wait('What javascript framework are you using')
- .sendCarriageReturn();
+ chain.sendCarriageReturn().wait('What javascript framework are you using').sendCarriageReturn();
break;
case AmplifyFrontend.android:
- chain
- .sendKeyDown()
- .sendCarriageReturn();
+ chain.sendKeyDown().sendCarriageReturn();
break;
case AmplifyFrontend.ios:
- chain
- .sendKeyDown(2)
- .sendCarriageReturn();
+ chain.sendKeyDown(2).sendCarriageReturn();
break;
case AmplifyFrontend.flutter:
- chain
- .sendKeyDown(3)
- .sendCarriageReturn();
+ chain.sendKeyDown(3).sendCarriageReturn();
break;
default:
- throw Error(`${settings.appType} is not a supported frontend in sandbox app.`)
+ throw Error(`${settings.appType} is not a supported frontend in sandbox app.`);
}
- chain
- .wait('Successfully generated models.')
- .run((err: Error) => {
- if (!err) {
- resolve({});
- } else {
- reject(err);
- }
- });
+ chain.wait('Successfully generated models.').run((err: Error) => {
+ if (!err) {
+ resolve({});
+ } else {
+ reject(err);
+ }
+ });
});
}
-function initializeFrontend(chain: ExecutionContext, config: AmplifyFrontendConfig) : void {
+function initializeFrontend(chain: ExecutionContext, config: AmplifyFrontendConfig): void {
chain.wait("Choose the type of app that you're building");
switch (config.frontendType) {
case AmplifyFrontend.android:
- chain
- .sendLine('android')
- .wait('Where is your Res directory')
- .sendCarriageReturn()
+ chain.sendLine('android').wait('Where is your Res directory').sendCarriageReturn();
return;
case AmplifyFrontend.ios:
- chain
- .sendKeyDown(3)
- .sendCarriageReturn()
+ chain.sendKeyDown(3).sendCarriageReturn();
return;
case AmplifyFrontend.flutter:
- chain
- .sendKeyDown(2)
- .sendCarriageReturn()
- .wait('Where do you want to store your configuration file')
- .sendCarriageReturn()
+ chain.sendKeyDown(2).sendCarriageReturn().wait('Where do you want to store your configuration file').sendCarriageReturn();
return;
case AmplifyFrontend.javascript:
default:
diff --git a/packages/amplify-codegen-e2e-core/src/init/amplifyPush.ts b/packages/amplify-codegen-e2e-core/src/init/amplifyPush.ts
index 8cff27aaa..820d14117 100644
--- a/packages/amplify-codegen-e2e-core/src/init/amplifyPush.ts
+++ b/packages/amplify-codegen-e2e-core/src/init/amplifyPush.ts
@@ -133,9 +133,7 @@ export function amplifyPushWithCodegenAdd(cwd: string, settings: any = {}, testi
.wait('Enter maximum statement depth [increase from default if your schema is deeply')
.sendCarriageReturn();
if (settings.frontendType === AmplifyFrontend.ios) {
- chain
- .wait('Enter the file name for the generated code')
- .sendCarriageReturn();
+ chain.wait('Enter the file name for the generated code').sendCarriageReturn();
}
chain.run((err: Error) => {
if (!err) {
@@ -158,11 +156,11 @@ export function amplifyPushWithCodegenUpdate(cwd: string, settings: any = {}, te
.wait('Do you want to generate GraphQL statements (queries, mutations and subscription) based on your schema types?')
.sendCarriageReturn()
.run((err: Error) => {
- if (!err) {
- resolve();
- } else {
- reject(err);
- }
- });
+ if (!err) {
+ resolve();
+ } else {
+ reject(err);
+ }
+ });
});
}
diff --git a/packages/amplify-codegen-e2e-core/src/init/android.ts b/packages/amplify-codegen-e2e-core/src/init/android.ts
index 70bd9e130..15e1e6f42 100644
--- a/packages/amplify-codegen-e2e-core/src/init/android.ts
+++ b/packages/amplify-codegen-e2e-core/src/init/android.ts
@@ -25,7 +25,7 @@ export function androidBuild(cwd: string, settings: Object = {}): Promise
}
});
});
-};
+}
export function acceptLicenses(cwd: string, settings: Object = {}): Promise {
return new Promise((resolve, reject) => {
@@ -34,10 +34,10 @@ export function acceptLicenses(cwd: string, settings: Object = {}): Promise {
if (err) {
@@ -47,4 +47,4 @@ export function acceptLicenses(cwd: string, settings: Object = {}): Promise describeCloudFormationStack(stackName, region, profileConfig),
- stack => stack.StackStatus.endsWith('_COMPLETE'),
+ (stack) => stack.StackStatus.endsWith('_COMPLETE'),
);
return new Promise((resolve, reject) => {
const noOutputTimeout = 1000 * 60 * 20; // 20 minutes;
diff --git a/packages/amplify-codegen-e2e-core/src/init/initProjectHelper.ts b/packages/amplify-codegen-e2e-core/src/init/initProjectHelper.ts
index 26b9ff1ad..e6451e1b3 100644
--- a/packages/amplify-codegen-e2e-core/src/init/initProjectHelper.ts
+++ b/packages/amplify-codegen-e2e-core/src/init/initProjectHelper.ts
@@ -22,7 +22,7 @@ const defaultSettings = {
providerConfig: undefined,
};
-const javaScriptFrameworkList = [ 'none', 'angular', 'ember', 'ionic', 'react', 'react-native', 'vue' ];
+const javaScriptFrameworkList = ['none', 'angular', 'ember', 'ionic', 'react', 'react-native', 'vue'];
export function initJSProjectWithProfile(cwd: string, settings: Object = {}): Promise {
const s = { ...defaultSettings, ...settings };
@@ -455,7 +455,5 @@ export async function initProjectWithQuickstart(cwd: string, settings: any): Pro
export function createRandomName() {
const length = 20;
const regExp = new RegExp('-', 'g');
- return uuid()
- .replace(regExp, '')
- .substring(0, length);
+ return uuid().replace(regExp, '').substring(0, length);
}
diff --git a/packages/amplify-codegen-e2e-core/src/nexpect-reporter.js b/packages/amplify-codegen-e2e-core/src/nexpect-reporter.js
index aa086dc72..89ec5f2d5 100644
--- a/packages/amplify-codegen-e2e-core/src/nexpect-reporter.js
+++ b/packages/amplify-codegen-e2e-core/src/nexpect-reporter.js
@@ -12,39 +12,39 @@ function imgToBase64(imgPath) {
return undefined;
}
-const filterBlock = blocks => blocks.filter(block => block.logs.length);
-const getLogs = blocks => filterBlock(blocks).reduce((sum, b) => [...sum, ...b.logs], []);
+const filterBlock = (blocks) => blocks.filter((block) => block.logs.length);
+const getLogs = (blocks) => filterBlock(blocks).reduce((sum, b) => [...sum, ...b.logs], []);
const mergeCliLog = (result, logs, ancestorTitles = [], prefix = '') => {
let before = [];
let after = [];
let children = [];
if (ancestorTitles.length) {
const describeBlockName = ancestorTitles[0];
- const describeBlock = logs.find(l => l.type === 'describe' && l.name === describeBlockName);
+ const describeBlock = logs.find((l) => l.type === 'describe' && l.name === describeBlockName);
if (describeBlock) {
const prefixStr = prefix ? `${prefix} -> ${describeBlockName}` : describeBlockName;
if (describeBlock.hooks.beforeAll) {
- before = getLogs(describeBlock.hooks.beforeAll).map(bfa => ({ ...bfa, name: `${prefixStr} -> BeforeAll` }));
+ before = getLogs(describeBlock.hooks.beforeAll).map((bfa) => ({ ...bfa, name: `${prefixStr} -> BeforeAll` }));
}
children = mergeCliLog(result, describeBlock.children, ancestorTitles.slice(1), prefixStr);
if (describeBlock.hooks.afterAll) {
- after = getLogs(describeBlock.hooks.afterAll).map(afa => ({ ...afa, name: `${prefixStr} --> AfterAll` }));
+ after = getLogs(describeBlock.hooks.afterAll).map((afa) => ({ ...afa, name: `${prefixStr} --> AfterAll` }));
}
}
} else {
- const testBlock = logs.find(l => l.type === 'test' && l.name === result.title);
+ const testBlock = logs.find((l) => l.type === 'test' && l.name === result.title);
if (testBlock) {
const prefixStr = prefix ? `${prefix} -> ${testBlock.name}` : testBlock.name;
if (testBlock.hooks.beforeEach) {
- before = getLogs(testBlock.hooks.beforeEach).map(bfe => ({ ...bfe, name: `${prefixStr} -> BeforeEach` }));
+ before = getLogs(testBlock.hooks.beforeEach).map((bfe) => ({ ...bfe, name: `${prefixStr} -> BeforeEach` }));
}
if (filterBlock([testBlock]).length) {
- children = testBlock.logs.map(log => ({ ...log, name: prefixStr }));
+ children = testBlock.logs.map((log) => ({ ...log, name: prefixStr }));
}
if (testBlock.hooks.afterEach) {
- after = getLogs(testBlock.hooks.afterEach).map(afe => ({ ...afe, name: `${prefixStr} --> AfterEach` }));
+ after = getLogs(testBlock.hooks.afterEach).map((afe) => ({ ...afe, name: `${prefixStr} --> AfterEach` }));
}
}
}
@@ -65,15 +65,15 @@ class AmplifyCLIExecutionReporter {
const reportPath = path.join(publicPath, runIdx);
fs.ensureDirSync(reportPath);
- const processedResults = results.testResults.map(result => {
+ const processedResults = results.testResults.map((result) => {
const resultCopy = { ...result };
delete resultCopy.CLITestRunner;
return {
...resultCopy,
- testResults: result.testResults.map(r => {
+ testResults: result.testResults.map((r) => {
const recordings = mergeCliLog(r, result.CLITestRunner.logs.children, r.ancestorTitles);
- const recordingWithPath = recordings.map(r => {
+ const recordingWithPath = recordings.map((r) => {
const castFile = `${uuid.v4()}.cast`;
const castFilePath = path.join(reportPath, castFile);
fs.writeFileSync(castFilePath, r.recording);
diff --git a/packages/amplify-codegen-e2e-core/src/utils/add-ci-tags.ts b/packages/amplify-codegen-e2e-core/src/utils/add-ci-tags.ts
index 04a4420cb..e8b41bf20 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/add-ci-tags.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/add-ci-tags.ts
@@ -13,7 +13,7 @@ export const addCITags = (projectPath: string): void => {
if (process.env && process.env['CODEBUILD']) {
addCodeBuildCITags(projectPath);
}
-}
+};
/**
* Add CI tags for code build
@@ -24,7 +24,7 @@ export const addCodeBuildCITags = (projectPath: string): void => {
const tags = stateManager.getProjectTags(projectPath);
const addTagIfNotExist = (key: string, value: string): void => {
- if (!tags.find(t => t.Key === key)) {
+ if (!tags.find((t) => t.Key === key)) {
tags.push({
Key: key,
Value: value,
diff --git a/packages/amplify-codegen-e2e-core/src/utils/admin-ui.ts b/packages/amplify-codegen-e2e-core/src/utils/admin-ui.ts
index 76e9dd2fa..6815883a6 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/admin-ui.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/admin-ui.ts
@@ -13,8 +13,8 @@ export async function getAdminApp(body: any): Promise {
path: adminUiUrl.path,
method: 'POST',
},
- res => {
- res.on('data', chunk => {
+ (res) => {
+ res.on('data', (chunk) => {
str += chunk;
});
res.on('end', () => {
@@ -22,7 +22,7 @@ export async function getAdminApp(body: any): Promise {
});
},
);
- req.on('error', err => {
+ req.on('error', (err) => {
reject(err);
});
req.write(JSON.stringify(body));
diff --git a/packages/amplify-codegen-e2e-core/src/utils/frontend-config-helper.ts b/packages/amplify-codegen-e2e-core/src/utils/frontend-config-helper.ts
index 27bea0ec1..5bf7fb78d 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/frontend-config-helper.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/frontend-config-helper.ts
@@ -11,41 +11,41 @@ export type JavaScriptFramework = 'none' | 'angular' | 'ember' | 'ionic' | 'reac
export type JavaScriptCodegenTarget = 'javascript' | 'typescript' | 'flow' | 'angular';
export type JavaScriptConfig = {
- frontendType: AmplifyFrontend.javascript,
- framework: JavaScriptFramework,
- codegenTarget?: JavaScriptCodegenTarget,
- srcDir: string,
- modelgenDir?: string,
- graphqlCodegenDir?: string,
-}
+ frontendType: AmplifyFrontend.javascript;
+ framework: JavaScriptFramework;
+ codegenTarget?: JavaScriptCodegenTarget;
+ srcDir: string;
+ modelgenDir?: string;
+ graphqlCodegenDir?: string;
+};
export type TypeScriptConfig = {
- frontendType: AmplifyFrontend.typescript,
- srcDir: string,
- modelgenDir?: string,
- graphqlCodegenDir?: string,
-}
+ frontendType: AmplifyFrontend.typescript;
+ srcDir: string;
+ modelgenDir?: string;
+ graphqlCodegenDir?: string;
+};
export type AndroidConfig = {
- frontendType: AmplifyFrontend.android,
- srcDir: string,
- modelgenDir?: string,
- graphqlCodegenDir?: string,
-}
+ frontendType: AmplifyFrontend.android;
+ srcDir: string;
+ modelgenDir?: string;
+ graphqlCodegenDir?: string;
+};
export type IOSConfig = {
- frontendType: AmplifyFrontend.ios,
- srcDir: string,
- modelgenDir?: string,
- graphqlCodegenDir?: string,
-}
+ frontendType: AmplifyFrontend.ios;
+ srcDir: string;
+ modelgenDir?: string;
+ graphqlCodegenDir?: string;
+};
export type FlutterConfig = {
- frontendType: AmplifyFrontend.flutter,
- srcDir: string,
- modelgenDir?: string,
- graphqlCodegenDir?: string,
-}
+ frontendType: AmplifyFrontend.flutter;
+ srcDir: string;
+ modelgenDir?: string;
+ graphqlCodegenDir?: string;
+};
export type AmplifyFrontendConfig = JavaScriptConfig | AndroidConfig | IOSConfig | FlutterConfig | TypeScriptConfig;
export const DEFAULT_JS_CONFIG: AmplifyFrontendConfig = {
@@ -54,7 +54,7 @@ export const DEFAULT_JS_CONFIG: AmplifyFrontendConfig = {
codegenTarget: 'javascript',
srcDir: 'src',
modelgenDir: 'src/models',
- graphqlCodegenDir : 'src/graphql',
+ graphqlCodegenDir: 'src/graphql',
};
// Config used for modelgen test only
@@ -62,24 +62,24 @@ export const DEFAULT_TS_CONFIG: AmplifyFrontendConfig = {
frontendType: AmplifyFrontend.typescript,
srcDir: 'src',
modelgenDir: 'src/models',
-}
+};
export const DEFAULT_ANDROID_CONFIG: AmplifyFrontendConfig = {
frontendType: AmplifyFrontend.android,
srcDir: 'app/src/main/res',
modelgenDir: 'app/src/main/java',
- graphqlCodegenDir : 'app/src/main/graphql/com/amazonaws/amplify/generated/graphql'
+ graphqlCodegenDir: 'app/src/main/graphql/com/amazonaws/amplify/generated/graphql',
};
export const DEFAULT_IOS_CONFIG: AmplifyFrontendConfig = {
frontendType: AmplifyFrontend.ios,
srcDir: '.',
modelgenDir: 'amplify/generated/models',
- graphqlCodegenDir : 'graphql'
+ graphqlCodegenDir: 'graphql',
};
export const DEFAULT_FLUTTER_CONFIG: AmplifyFrontendConfig = {
frontendType: AmplifyFrontend.flutter,
srcDir: 'lib',
modelgenDir: 'lib/models',
-};
\ No newline at end of file
+};
diff --git a/packages/amplify-codegen-e2e-core/src/utils/getCommandPath.ts b/packages/amplify-codegen-e2e-core/src/utils/getCommandPath.ts
index c078e7ac6..4f26044d0 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/getCommandPath.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/getCommandPath.ts
@@ -4,7 +4,5 @@ import { execSync } from 'child_process';
* Windows executors on CB fail to spawn a command with custom nexpect unless the full path is used.
*/
export function getCommandPath(command: string): string {
- return execSync(`which ${command}`)
- .toString()
- .trim();
+ return execSync(`which ${command}`).toString().trim();
}
diff --git a/packages/amplify-codegen-e2e-core/src/utils/graphql-config-helper.ts b/packages/amplify-codegen-e2e-core/src/utils/graphql-config-helper.ts
index 61aecd9bd..5cf940e65 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/graphql-config-helper.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/graphql-config-helper.ts
@@ -1,53 +1,53 @@
import { AmplifyFrontendConfig, AmplifyFrontend } from './frontend-config-helper';
export function constructGraphQLConfig(
- projectName: string,
- config: AmplifyFrontendConfig,
- maxDepth: number,
- region: string,
- isConfigured: boolean = false,
- apiId: string = null) : any {
+ projectName: string,
+ config: AmplifyFrontendConfig,
+ maxDepth: number,
+ region: string,
+ isConfigured: boolean = false,
+ apiId: string = null,
+): any {
+ let schemaPath: string;
+ let includes: [string];
+ let excludes: [string] = ['./amplify/**'];
+ let extensions = {
+ amplify: {
+ apiId: apiId,
+ codeGenTarget: '',
+ docsFilePath: '',
+ generatedFileName: '',
+ maxDepth: maxDepth ? maxDepth : 2,
+ region: region,
+ },
+ };
- let schemaPath: string;
- let includes: [string];
- let excludes: [string] = ['./amplify/**'];
- let extensions = {
- amplify: {
- apiId: apiId,
- codeGenTarget: '',
- docsFilePath: '',
- generatedFileName: '',
- maxDepth: maxDepth ? maxDepth : 2,
- region: region
- }
- };
-
- switch (config.frontendType) {
- case AmplifyFrontend.android:
- schemaPath = 'app/src/main/graphql/schema.json';
- includes = ['app/src/main/graphql/**/*.graphql'];
- extensions.amplify.codeGenTarget = isConfigured ? 'android' : '';
- extensions.amplify.docsFilePath = 'app/src/main/graphql/com/amazonaws/amplify/generated/graphql';
- break;
- case AmplifyFrontend.ios:
- schemaPath = `amplify/backend/api/${projectName}/build/schema.graphql`;
- includes = ['graphql/**/*.graphql'];
- extensions.amplify.codeGenTarget = 'swift';
- extensions.amplify.docsFilePath = 'graphql';
- extensions.amplify.generatedFileName = 'API.swift';
- excludes.push('API.swift');
- break;
- default:
- schemaPath = `amplify/backend/api/${projectName}/build/schema.graphql`;
- includes = ['src/graphql/**/*.js'];
- extensions.amplify.codeGenTarget = 'javascript';
- extensions.amplify.docsFilePath = 'src/graphql';
- }
-
- return {
- schemaPath: schemaPath,
- includes: includes,
- excludes: excludes,
- extensions: extensions
- };
+ switch (config.frontendType) {
+ case AmplifyFrontend.android:
+ schemaPath = 'app/src/main/graphql/schema.json';
+ includes = ['app/src/main/graphql/**/*.graphql'];
+ extensions.amplify.codeGenTarget = isConfigured ? 'android' : '';
+ extensions.amplify.docsFilePath = 'app/src/main/graphql/com/amazonaws/amplify/generated/graphql';
+ break;
+ case AmplifyFrontend.ios:
+ schemaPath = `amplify/backend/api/${projectName}/build/schema.graphql`;
+ includes = ['graphql/**/*.graphql'];
+ extensions.amplify.codeGenTarget = 'swift';
+ extensions.amplify.docsFilePath = 'graphql';
+ extensions.amplify.generatedFileName = 'API.swift';
+ excludes.push('API.swift');
+ break;
+ default:
+ schemaPath = `amplify/backend/api/${projectName}/build/schema.graphql`;
+ includes = ['src/graphql/**/*.js'];
+ extensions.amplify.codeGenTarget = 'javascript';
+ extensions.amplify.docsFilePath = 'src/graphql';
}
+
+ return {
+ schemaPath: schemaPath,
+ includes: includes,
+ excludes: excludes,
+ extensions: extensions,
+ };
+}
diff --git a/packages/amplify-codegen-e2e-core/src/utils/isWindows.ts b/packages/amplify-codegen-e2e-core/src/utils/isWindows.ts
index 2d48cd9fe..5d73cf5d4 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/isWindows.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/isWindows.ts
@@ -1,5 +1,5 @@
import os from 'os';
export function isWindows(): boolean {
- return os.platform() === 'win32'
+ return os.platform() === 'win32';
}
diff --git a/packages/amplify-codegen-e2e-core/src/utils/projectMeta.ts b/packages/amplify-codegen-e2e-core/src/utils/projectMeta.ts
index 5195b2e88..746f5dc40 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/projectMeta.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/projectMeta.ts
@@ -66,7 +66,7 @@ function getTeamProviderInfo(projectRoot: string) {
function getS3StorageBucketName(projectRoot: string) {
const meta = getProjectMeta(projectRoot);
const storage = meta['storage'];
- const s3 = Object.keys(storage).filter(r => storage[r].service === 'S3');
+ const s3 = Object.keys(storage).filter((r) => storage[r].service === 'S3');
const fStorageName = s3[0];
return storage[fStorageName].output.BucketName;
}
@@ -100,7 +100,7 @@ function isDeploymentSecretForEnvExists(projRoot: string, envName: string): bool
const rootStackId = teamproviderInfo[envName].awscloudformation.StackId.split('/')[2];
const resource = _.first(Object.keys(teamproviderInfo[envName].categories.auth));
const deploymentSecrets = getDeploymentSecrets();
- const deploymentSecretByAppId = _.find(deploymentSecrets.appSecrets, appSecret => appSecret.rootStackId === rootStackId);
+ const deploymentSecretByAppId = _.find(deploymentSecrets.appSecrets, (appSecret) => appSecret.rootStackId === rootStackId);
if (deploymentSecretByAppId) {
const path = [envName, 'auth', resource, 'hostedUIProviderCreds'];
return _.has(deploymentSecretByAppId.environments, path);
diff --git a/packages/amplify-codegen-e2e-core/src/utils/request.ts b/packages/amplify-codegen-e2e-core/src/utils/request.ts
index 90233998b..6521b63d1 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/request.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/request.ts
@@ -7,9 +7,9 @@ export function post({ body, ...options }) {
method: 'POST',
...options,
},
- res => {
+ (res) => {
const chunks = [];
- res.on('data', data => chunks.push(data));
+ res.on('data', (data) => chunks.push(data));
res.on('end', () => {
let body = Buffer.concat(chunks);
if (res.headers['content-type'].startsWith('application/json')) {
diff --git a/packages/amplify-codegen-e2e-core/src/utils/sdk-calls.ts b/packages/amplify-codegen-e2e-core/src/utils/sdk-calls.ts
index f132944b0..04206bcff 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/sdk-calls.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/sdk-calls.ts
@@ -82,7 +82,7 @@ export const deleteS3Bucket = async (bucket: string, providedS3Client: S3 | unde
} while (truncated);
const chunkedResult = _.chunk(objectKeyAndVersion, 1000);
const deleteReq = chunkedResult
- .map(r => {
+ .map((r) => {
return {
Bucket: bucket,
Delete: {
@@ -91,7 +91,7 @@ export const deleteS3Bucket = async (bucket: string, providedS3Client: S3 | unde
},
};
})
- .map(delParams => s3.deleteObjects(delParams).promise());
+ .map((delParams) => s3.deleteObjects(delParams).promise());
await Promise.all(deleteReq);
await s3
.deleteBucket({
@@ -214,7 +214,7 @@ export const getCloudWatchLogs = async (region: string, logGroupName: string, lo
export const describeCloudFormationStack = async (stackName: string, region: string, profileConfig?: any) => {
const service = profileConfig ? new CloudFormation(profileConfig) : new CloudFormation({ region });
return (await service.describeStacks({ StackName: stackName }).promise()).Stacks.find(
- stack => stack.StackName === stackName || stack.StackId === stackName,
+ (stack) => stack.StackName === stackName || stack.StackId === stackName,
);
};
diff --git a/packages/amplify-codegen-e2e-core/src/utils/selectors.ts b/packages/amplify-codegen-e2e-core/src/utils/selectors.ts
index c847e817d..e761c582e 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/selectors.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/selectors.ts
@@ -10,8 +10,8 @@ export const singleSelect = (chain: ExecutionContext, item: T, allChoices: T[
export const multiSelect = (chain: ExecutionContext, items: T[] = [], allChoices: T[]) => {
items
- .map(item => allChoices.indexOf(item))
- .filter(idx => idx > -1)
+ .map((item) => allChoices.indexOf(item))
+ .filter((idx) => idx > -1)
.sort()
// calculate the diff with the latest, since items are sorted, always positive
// represents the numbers of moves down we need to make to selection
diff --git a/packages/amplify-codegen-e2e-core/src/utils/sleep.ts b/packages/amplify-codegen-e2e-core/src/utils/sleep.ts
index 2be57ca74..7c47d22fe 100644
--- a/packages/amplify-codegen-e2e-core/src/utils/sleep.ts
+++ b/packages/amplify-codegen-e2e-core/src/utils/sleep.ts
@@ -1,3 +1,3 @@
export function sleep(millis) {
- return new Promise(resolve => setTimeout(resolve, millis));
+ return new Promise((resolve) => setTimeout(resolve, millis));
}
diff --git a/packages/amplify-codegen-e2e-tests/functions/get-api-appsync.js b/packages/amplify-codegen-e2e-tests/functions/get-api-appsync.js
index 5db92cb63..e2a6122bc 100644
--- a/packages/amplify-codegen-e2e-tests/functions/get-api-appsync.js
+++ b/packages/amplify-codegen-e2e-tests/functions/get-api-appsync.js
@@ -4,7 +4,7 @@ const AWS = require('aws-sdk');
const getGqlApi = async (idKey) => {
const appsync = new AWS.AppSync({ region: process.env.REGION });
return await appsync.getGraphqlApi({ apiId: process.env[idKey] }).promise();
-}
+};
exports.handler = async (event) => {
return await getGqlApi(event.idKey);
diff --git a/packages/amplify-codegen-e2e-tests/functions/mutation-appsync.js b/packages/amplify-codegen-e2e-tests/functions/mutation-appsync.js
index e5f321fb8..8ef68db28 100644
--- a/packages/amplify-codegen-e2e-tests/functions/mutation-appsync.js
+++ b/packages/amplify-codegen-e2e-tests/functions/mutation-appsync.js
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
-require("isomorphic-fetch");
+require('isomorphic-fetch');
const AWS = require('aws-sdk');
-const AWSAppSyncClient = require("aws-appsync").default;
-const { AUTH_TYPE } = require("aws-appsync");
+const AWSAppSyncClient = require('aws-appsync').default;
+const { AUTH_TYPE } = require('aws-appsync');
const gql = require('graphql-tag');
const runGQLMutation = async (gql_url, mutation, variables) => {
@@ -10,10 +10,10 @@ const runGQLMutation = async (gql_url, mutation, variables) => {
url: process.env[gql_url],
region: process.env.REGION,
auth: {
- type: AUTH_TYPE.AWS_IAM,
- credentials: AWS.config.credentials
+ type: AUTH_TYPE.AWS_IAM,
+ credentials: AWS.config.credentials,
},
- disableOffline: true
+ disableOffline: true,
});
return await client.mutate({ mutation: gql(mutation), variables });
};
diff --git a/packages/amplify-codegen-e2e-tests/schemas/admin-modelgen.graphql b/packages/amplify-codegen-e2e-tests/schemas/admin-modelgen.graphql
index a2ecffa17..7182d5518 100644
--- a/packages/amplify-codegen-e2e-tests/schemas/admin-modelgen.graphql
+++ b/packages/amplify-codegen-e2e-tests/schemas/admin-modelgen.graphql
@@ -1,5 +1,6 @@
-input AMPLIFY { globalAuthRule: AuthRule = { allow: public } } # FOR TESTING ONLY!
-
+input AMPLIFY {
+ globalAuthRule: AuthRule = { allow: public }
+} # FOR TESTING ONLY!
type Todo @model {
id: ID!
name: String!
@@ -42,12 +43,11 @@ type Query {
echo6(customInput: CustomInput): String!
echo7: [ICustom]!
echo8(msg: [Float], msg2: [Int!], enumType: BillingSource, enumList: [BillingSource], inputType: [CustomInput]): [String]
- echo9(msg: [Float]!, msg2: [Int!]!, enumType: BillingSource!, enumList: [BillingSource!]!, inputType: [CustomInput!]!): [String!]!
-
+ echo9(msg: [Float]!, msg2: [Int!]!, enumType: BillingSource!, enumList: [BillingSource!]!, inputType: [CustomInput!]!): [String!]!
}
type Mutation {
mutate(msg: [String!]!): Todo
}
type Subscription {
onMutate(msg: String): [Todo!]
-}
\ No newline at end of file
+}
diff --git a/packages/amplify-codegen-e2e-tests/schemas/key-conflict-detection.graphql b/packages/amplify-codegen-e2e-tests/schemas/key-conflict-detection.graphql
index 39df6d8c7..ba9bc50ab 100644
--- a/packages/amplify-codegen-e2e-tests/schemas/key-conflict-detection.graphql
+++ b/packages/amplify-codegen-e2e-tests/schemas/key-conflict-detection.graphql
@@ -1,4 +1,4 @@
type Note @model @key(fields: ["noteId"]) {
noteId: String!
note: String
-}
\ No newline at end of file
+}
diff --git a/packages/amplify-codegen-e2e-tests/schemas/migrations_key/four_key_model_schema.graphql b/packages/amplify-codegen-e2e-tests/schemas/migrations_key/four_key_model_schema.graphql
index 87f74defd..bf573187d 100644
--- a/packages/amplify-codegen-e2e-tests/schemas/migrations_key/four_key_model_schema.graphql
+++ b/packages/amplify-codegen-e2e-tests/schemas/migrations_key/four_key_model_schema.graphql
@@ -1,19 +1,13 @@
-type Todo @model
- @key(name: "byDescription", fields: ["description"])
- @key(name: "byName", fields: ["name"])
- {
+type Todo @model @key(name: "byDescription", fields: ["description"]) @key(name: "byName", fields: ["name"]) {
id: ID!
name: String!
description: String
}
-
-type Post @model @key(name: "byCreatedAt", fields: ["createdAt"])
-@key(name: "byUpdatedAt", fields: ["updatedAt"])
-{
+type Post @model @key(name: "byCreatedAt", fields: ["createdAt"]) @key(name: "byUpdatedAt", fields: ["updatedAt"]) {
id: ID!
name: String!
description: String
createdAt: AWSDateTime
updatedAt: AWSDateTime
-}
\ No newline at end of file
+}
diff --git a/packages/amplify-codegen-e2e-tests/schemas/migrations_key/two_key_model_schema.graphql b/packages/amplify-codegen-e2e-tests/schemas/migrations_key/two_key_model_schema.graphql
index 81c7cc660..53eb2fd63 100644
--- a/packages/amplify-codegen-e2e-tests/schemas/migrations_key/two_key_model_schema.graphql
+++ b/packages/amplify-codegen-e2e-tests/schemas/migrations_key/two_key_model_schema.graphql
@@ -4,11 +4,10 @@ type Todo @model @key(name: "byDescription", fields: ["description"]) {
description: String
}
-
type Post @model @key(name: "byCreatedAt", fields: ["createdAt"]) {
id: ID!
name: String!
description: String
createdAt: AWSDateTime
updatedAt: AWSDateTime
-}
\ No newline at end of file
+}
diff --git a/packages/amplify-codegen-e2e-tests/schemas/sdl/schema.json b/packages/amplify-codegen-e2e-tests/schemas/sdl/schema.json
index b133d772b..b0d80af26 100644
--- a/packages/amplify-codegen-e2e-tests/schemas/sdl/schema.json
+++ b/packages/amplify-codegen-e2e-tests/schemas/sdl/schema.json
@@ -1,1163 +1,1129 @@
{
- "data": {
- "__schema": {
- "queryType": {
- "name": "Query"
+ "data": {
+ "__schema": {
+ "queryType": {
+ "name": "Query"
+ },
+ "mutationType": {
+ "name": "Mutation"
+ },
+ "subscriptionType": {
+ "name": "Subscription"
+ },
+ "types": [
+ {
+ "kind": "OBJECT",
+ "name": "Query",
+ "description": null,
+ "fields": [
+ {
+ "name": "echo",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "SCALAR",
+ "name": "String",
+ "description": "Built-in String",
+ "fields": null,
+ "inputFields": null,
+ "interfaces": null,
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "Mutation",
+ "description": null,
+ "fields": [
+ {
+ "name": "mymutation",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "Subscription",
+ "description": null,
+ "fields": [
+ {
+ "name": "mysub",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "__Schema",
+ "description": "A GraphQL Introspection defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, the entry points for query, mutation, and subscription operations.",
+ "fields": [
+ {
+ "name": "types",
+ "description": "A list of all types supported by this server.",
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "OBJECT",
+ "name": "__Type",
+ "ofType": null
+ }
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
},
- "mutationType": {
- "name": "Mutation"
+ {
+ "name": "queryType",
+ "description": "The type that query operations will be rooted at.",
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "OBJECT",
+ "name": "__Type",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
},
- "subscriptionType": {
- "name": "Subscription"
+ {
+ "name": "mutationType",
+ "description": "If this server supports mutation, the type that mutation operations will be rooted at.",
+ "args": [],
+ "type": {
+ "kind": "OBJECT",
+ "name": "__Type",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
},
- "types": [
- {
- "kind": "OBJECT",
- "name": "Query",
- "description": null,
- "fields": [
- {
- "name": "echo",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
+ {
+ "name": "directives",
+ "description": "'A list of all directives supported by this server.",
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "OBJECT",
+ "name": "__Directive",
+ "ofType": null
+ }
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "subscriptionType",
+ "description": "'If this server support subscription, the type that subscription operations will be rooted at.",
+ "args": [],
+ "type": {
+ "kind": "OBJECT",
+ "name": "__Type",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "__Type",
+ "description": null,
+ "fields": [
+ {
+ "name": "kind",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "ENUM",
+ "name": "__TypeKind",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "name",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "description",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "fields",
+ "description": null,
+ "args": [
{
+ "name": "includeDeprecated",
+ "description": null,
+ "type": {
"kind": "SCALAR",
- "name": "String",
- "description": "Built-in String",
- "fields": null,
- "inputFields": null,
- "interfaces": null,
- "enumValues": null,
- "possibleTypes": null
- },
- {
- "kind": "OBJECT",
- "name": "Mutation",
- "description": null,
- "fields": [
- {
- "name": "mymutation",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
- {
- "kind": "OBJECT",
- "name": "Subscription",
- "description": null,
- "fields": [
- {
- "name": "mysub",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
- {
+ "name": "Boolean",
+ "ofType": null
+ },
+ "defaultValue": "false"
+ }
+ ],
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
"kind": "OBJECT",
- "name": "__Schema",
- "description": "A GraphQL Introspection defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, the entry points for query, mutation, and subscription operations.",
- "fields": [
- {
- "name": "types",
- "description": "A list of all types supported by this server.",
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- }
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "queryType",
- "description": "The type that query operations will be rooted at.",
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "mutationType",
- "description": "If this server supports mutation, the type that mutation operations will be rooted at.",
- "args": [],
- "type": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "directives",
- "description": "'A list of all directives supported by this server.",
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__Directive",
- "ofType": null
- }
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "subscriptionType",
- "description": "'If this server support subscription, the type that subscription operations will be rooted at.",
- "args": [],
- "type": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
- {
+ "name": "__Field",
+ "ofType": null
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "interfaces",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
"kind": "OBJECT",
"name": "__Type",
- "description": null,
- "fields": [
- {
- "name": "kind",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "ENUM",
- "name": "__TypeKind",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "name",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "description",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "fields",
- "description": null,
- "args": [
- {
- "name": "includeDeprecated",
- "description": null,
- "type": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- },
- "defaultValue": "false"
- }
- ],
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__Field",
- "ofType": null
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "interfaces",
- "description": null,
- "args": [],
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "possibleTypes",
- "description": null,
- "args": [],
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "enumValues",
- "description": null,
- "args": [
- {
- "name": "includeDeprecated",
- "description": null,
- "type": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- },
- "defaultValue": "false"
- }
- ],
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__EnumValue",
- "ofType": null
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "inputFields",
- "description": null,
- "args": [],
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__InputValue",
- "ofType": null
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "ofType",
- "description": null,
- "args": [],
- "type": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
- {
- "kind": "ENUM",
- "name": "__TypeKind",
- "description": "An enum describing what kind of type a given __Type is",
- "fields": null,
- "inputFields": null,
- "interfaces": null,
- "enumValues": [
- {
- "name": "SCALAR",
- "description": "Indicates this type is a scalar.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "OBJECT",
- "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "INTERFACE",
- "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "UNION",
- "description": "Indicates this type is a union. `possibleTypes` is a valid field.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "ENUM",
- "description": "Indicates this type is an enum. `enumValues` is a valid field.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "INPUT_OBJECT",
- "description": "Indicates this type is an input object. `inputFields` is a valid field.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "LIST",
- "description": "Indicates this type is a list. `ofType` is a valid field.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "NON_NULL",
- "description": "Indicates this type is a non-null. `ofType` is a valid field.",
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "possibleTypes": null
- },
- {
- "kind": "OBJECT",
- "name": "__Field",
- "description": null,
- "fields": [
- {
- "name": "name",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "description",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "args",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__InputValue",
- "ofType": null
- }
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "type",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "isDeprecated",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "deprecationReason",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
- {
+ "ofType": null
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "possibleTypes",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
"kind": "OBJECT",
- "name": "__InputValue",
- "description": null,
- "fields": [
- {
- "name": "name",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "description",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "type",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__Type",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "defaultValue",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
+ "name": "__Type",
+ "ofType": null
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "enumValues",
+ "description": null,
+ "args": [
{
+ "name": "includeDeprecated",
+ "description": null,
+ "type": {
"kind": "SCALAR",
"name": "Boolean",
- "description": "Built-in Boolean",
- "fields": null,
- "inputFields": null,
- "interfaces": null,
- "enumValues": null,
- "possibleTypes": null
- },
- {
+ "ofType": null
+ },
+ "defaultValue": "false"
+ }
+ ],
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
"kind": "OBJECT",
"name": "__EnumValue",
- "description": null,
- "fields": [
- {
- "name": "name",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "description",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "isDeprecated",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "deprecationReason",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
- {
+ "ofType": null
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "inputFields",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
"kind": "OBJECT",
- "name": "__Directive",
- "description": null,
- "fields": [
- {
- "name": "name",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "description",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "locations",
- "description": null,
- "args": [],
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "ENUM",
- "name": "__DirectiveLocation",
- "ofType": null
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "args",
- "description": null,
- "args": [],
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "OBJECT",
- "name": "__InputValue",
- "ofType": null
- }
- }
- }
- },
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "onOperation",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- },
- "isDeprecated": true,
- "deprecationReason": "Use `locations`."
- },
- {
- "name": "onFragment",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- },
- "isDeprecated": true,
- "deprecationReason": "Use `locations`."
- },
- {
- "name": "onField",
- "description": null,
- "args": [],
- "type": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- },
- "isDeprecated": true,
- "deprecationReason": "Use `locations`."
- }
- ],
- "inputFields": null,
- "interfaces": [],
- "enumValues": null,
- "possibleTypes": null
- },
- {
+ "name": "__InputValue",
+ "ofType": null
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "ofType",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "OBJECT",
+ "name": "__Type",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "ENUM",
+ "name": "__TypeKind",
+ "description": "An enum describing what kind of type a given __Type is",
+ "fields": null,
+ "inputFields": null,
+ "interfaces": null,
+ "enumValues": [
+ {
+ "name": "SCALAR",
+ "description": "Indicates this type is a scalar.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "OBJECT",
+ "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "INTERFACE",
+ "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "UNION",
+ "description": "Indicates this type is a union. `possibleTypes` is a valid field.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "ENUM",
+ "description": "Indicates this type is an enum. `enumValues` is a valid field.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "INPUT_OBJECT",
+ "description": "Indicates this type is an input object. `inputFields` is a valid field.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "LIST",
+ "description": "Indicates this type is a list. `ofType` is a valid field.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "NON_NULL",
+ "description": "Indicates this type is a non-null. `ofType` is a valid field.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "__Field",
+ "description": null,
+ "fields": [
+ {
+ "name": "name",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "description",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "args",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "OBJECT",
+ "name": "__InputValue",
+ "ofType": null
+ }
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "type",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "OBJECT",
+ "name": "__Type",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "isDeprecated",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "Boolean",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "deprecationReason",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "__InputValue",
+ "description": null,
+ "fields": [
+ {
+ "name": "name",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "description",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "type",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "OBJECT",
+ "name": "__Type",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "defaultValue",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "SCALAR",
+ "name": "Boolean",
+ "description": "Built-in Boolean",
+ "fields": null,
+ "inputFields": null,
+ "interfaces": null,
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "__EnumValue",
+ "description": null,
+ "fields": [
+ {
+ "name": "name",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "description",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "isDeprecated",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "Boolean",
+ "ofType": null
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "deprecationReason",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "OBJECT",
+ "name": "__Directive",
+ "description": null,
+ "fields": [
+ {
+ "name": "name",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "description",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "locations",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
"kind": "ENUM",
"name": "__DirectiveLocation",
- "description": "An enum describing valid locations where a directive can be placed",
- "fields": null,
- "inputFields": null,
- "interfaces": null,
- "enumValues": [
- {
- "name": "QUERY",
- "description": "Indicates the directive is valid on queries.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "MUTATION",
- "description": "Indicates the directive is valid on mutations.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "FIELD",
- "description": "Indicates the directive is valid on fields.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "FRAGMENT_DEFINITION",
- "description": "Indicates the directive is valid on fragment definitions.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "FRAGMENT_SPREAD",
- "description": "Indicates the directive is valid on fragment spreads.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "INLINE_FRAGMENT",
- "description": "Indicates the directive is valid on inline fragments.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "SCHEMA",
- "description": "Indicates the directive is valid on a schema SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "SCALAR",
- "description": "Indicates the directive is valid on a scalar SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "OBJECT",
- "description": "Indicates the directive is valid on an object SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "FIELD_DEFINITION",
- "description": "Indicates the directive is valid on a field SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "ARGUMENT_DEFINITION",
- "description": "Indicates the directive is valid on a field argument SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "INTERFACE",
- "description": "Indicates the directive is valid on an interface SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "UNION",
- "description": "Indicates the directive is valid on an union SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "ENUM",
- "description": "Indicates the directive is valid on an enum SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "ENUM_VALUE",
- "description": "Indicates the directive is valid on an enum value SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "INPUT_OBJECT",
- "description": "Indicates the directive is valid on an input object SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- },
- {
- "name": "INPUT_FIELD_DEFINITION",
- "description": "Indicates the directive is valid on an input object field SDL definition.",
- "isDeprecated": false,
- "deprecationReason": null
- }
- ],
- "possibleTypes": null
+ "ofType": null
+ }
}
- ],
- "directives": [
- {
- "name": "include",
- "description": "Directs the executor to include this field or fragment only when the `if` argument is true",
- "locations": [
- "FIELD",
- "FRAGMENT_SPREAD",
- "INLINE_FRAGMENT"
- ],
- "args": [
- {
- "name": "if",
- "description": "Included when true.",
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- }
- },
- "defaultValue": null
- }
- ],
- "onOperation": false,
- "onFragment": true,
- "onField": true
- },
- {
- "name": "skip",
- "description": "Directs the executor to skip this field or fragment when the `if`'argument is true.",
- "locations": [
- "FIELD",
- "FRAGMENT_SPREAD",
- "INLINE_FRAGMENT"
- ],
- "args": [
- {
- "name": "if",
- "description": "Skipped when true.",
- "type": {
- "kind": "NON_NULL",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "Boolean",
- "ofType": null
- }
- },
- "defaultValue": null
- }
- ],
- "onOperation": false,
- "onFragment": true,
- "onField": true
- },
- {
- "name": "defer",
- "description": "This directive allows results to be deferred during execution",
- "locations": [
- "FIELD"
- ],
- "args": [],
- "onOperation": false,
- "onFragment": false,
- "onField": true
- },
- {
- "name": "aws_api_key",
- "description": "Tells the service this field/object has access authorized by an API key.",
- "locations": [
- "OBJECT",
- "FIELD_DEFINITION"
- ],
- "args": [],
- "onOperation": false,
- "onFragment": false,
- "onField": false
- },
- {
- "name": "aws_iam",
- "description": "Tells the service this field/object has access authorized by sigv4 signing.",
- "locations": [
- "OBJECT",
- "FIELD_DEFINITION"
- ],
- "args": [],
- "onOperation": false,
- "onFragment": false,
- "onField": false
- },
- {
- "name": "aws_oidc",
- "description": "Tells the service this field/object has access authorized by an OIDC token.",
- "locations": [
- "OBJECT",
- "FIELD_DEFINITION"
- ],
- "args": [],
- "onOperation": false,
- "onFragment": false,
- "onField": false
- },
- {
- "name": "aws_lambda",
- "description": "Tells the service this field/object has access authorized by a Lambda Authorizer.",
- "locations": [
- "OBJECT",
- "FIELD_DEFINITION"
- ],
- "args": [],
- "onOperation": false,
- "onFragment": false,
- "onField": false
- },
- {
- "name": "aws_subscribe",
- "description": "Tells the service which mutation triggers this subscription.",
- "locations": [
- "FIELD_DEFINITION"
- ],
- "args": [
- {
- "name": "mutations",
- "description": "List of mutations which will trigger this subscription when they are called.",
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
- },
- "defaultValue": null
- }
- ],
- "onOperation": false,
- "onFragment": false,
- "onField": false
- },
- {
- "name": "aws_cognito_user_pools",
- "description": "Tells the service this field/object has access authorized by a Cognito User Pools token.",
- "locations": [
- "OBJECT",
- "FIELD_DEFINITION"
- ],
- "args": [
- {
- "name": "cognito_groups",
- "description": "List of cognito user pool groups which have access on this field",
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
- },
- "defaultValue": null
- }
- ],
- "onOperation": false,
- "onFragment": false,
- "onField": false
- },
- {
- "name": "deprecated",
- "description": null,
- "locations": [
- "FIELD_DEFINITION",
- "ENUM_VALUE"
- ],
- "args": [
- {
- "name": "reason",
- "description": null,
- "type": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- },
- "defaultValue": "\"No longer supported\""
- }
- ],
- "onOperation": false,
- "onFragment": false,
- "onField": false
- },
- {
- "name": "aws_auth",
- "description": "Directs the schema to enforce authorization on a field",
- "locations": [
- "FIELD_DEFINITION"
- ],
- "args": [
- {
- "name": "cognito_groups",
- "description": "List of cognito user pool groups which have access on this field",
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
- },
- "defaultValue": null
- }
- ],
- "onOperation": false,
- "onFragment": false,
- "onField": false
- },
- {
- "name": "aws_publish",
- "description": "Tells the service which subscriptions will be published to when this mutation is called. This directive is deprecated use @aws_susbscribe directive instead.",
- "locations": [
- "FIELD_DEFINITION"
- ],
- "args": [
- {
- "name": "subscriptions",
- "description": "List of subscriptions which will be published to when this mutation is called.",
- "type": {
- "kind": "LIST",
- "name": null,
- "ofType": {
- "kind": "SCALAR",
- "name": "String",
- "ofType": null
- }
- },
- "defaultValue": null
- }
- ],
- "onOperation": false,
- "onFragment": false,
- "onField": false
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "args",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "OBJECT",
+ "name": "__InputValue",
+ "ofType": null
+ }
+ }
+ }
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "onOperation",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "Boolean",
+ "ofType": null
+ },
+ "isDeprecated": true,
+ "deprecationReason": "Use `locations`."
+ },
+ {
+ "name": "onFragment",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "Boolean",
+ "ofType": null
+ },
+ "isDeprecated": true,
+ "deprecationReason": "Use `locations`."
+ },
+ {
+ "name": "onField",
+ "description": null,
+ "args": [],
+ "type": {
+ "kind": "SCALAR",
+ "name": "Boolean",
+ "ofType": null
+ },
+ "isDeprecated": true,
+ "deprecationReason": "Use `locations`."
+ }
+ ],
+ "inputFields": null,
+ "interfaces": [],
+ "enumValues": null,
+ "possibleTypes": null
+ },
+ {
+ "kind": "ENUM",
+ "name": "__DirectiveLocation",
+ "description": "An enum describing valid locations where a directive can be placed",
+ "fields": null,
+ "inputFields": null,
+ "interfaces": null,
+ "enumValues": [
+ {
+ "name": "QUERY",
+ "description": "Indicates the directive is valid on queries.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "MUTATION",
+ "description": "Indicates the directive is valid on mutations.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "FIELD",
+ "description": "Indicates the directive is valid on fields.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "FRAGMENT_DEFINITION",
+ "description": "Indicates the directive is valid on fragment definitions.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "FRAGMENT_SPREAD",
+ "description": "Indicates the directive is valid on fragment spreads.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "INLINE_FRAGMENT",
+ "description": "Indicates the directive is valid on inline fragments.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "SCHEMA",
+ "description": "Indicates the directive is valid on a schema SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "SCALAR",
+ "description": "Indicates the directive is valid on a scalar SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "OBJECT",
+ "description": "Indicates the directive is valid on an object SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "FIELD_DEFINITION",
+ "description": "Indicates the directive is valid on a field SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "ARGUMENT_DEFINITION",
+ "description": "Indicates the directive is valid on a field argument SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "INTERFACE",
+ "description": "Indicates the directive is valid on an interface SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "UNION",
+ "description": "Indicates the directive is valid on an union SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "ENUM",
+ "description": "Indicates the directive is valid on an enum SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "ENUM_VALUE",
+ "description": "Indicates the directive is valid on an enum value SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "INPUT_OBJECT",
+ "description": "Indicates the directive is valid on an input object SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
+ "name": "INPUT_FIELD_DEFINITION",
+ "description": "Indicates the directive is valid on an input object field SDL definition.",
+ "isDeprecated": false,
+ "deprecationReason": null
+ }
+ ],
+ "possibleTypes": null
+ }
+ ],
+ "directives": [
+ {
+ "name": "include",
+ "description": "Directs the executor to include this field or fragment only when the `if` argument is true",
+ "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
+ "args": [
+ {
+ "name": "if",
+ "description": "Included when true.",
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "Boolean",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ }
+ ],
+ "onOperation": false,
+ "onFragment": true,
+ "onField": true
+ },
+ {
+ "name": "skip",
+ "description": "Directs the executor to skip this field or fragment when the `if`'argument is true.",
+ "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
+ "args": [
+ {
+ "name": "if",
+ "description": "Skipped when true.",
+ "type": {
+ "kind": "NON_NULL",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "Boolean",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ }
+ ],
+ "onOperation": false,
+ "onFragment": true,
+ "onField": true
+ },
+ {
+ "name": "defer",
+ "description": "This directive allows results to be deferred during execution",
+ "locations": ["FIELD"],
+ "args": [],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": true
+ },
+ {
+ "name": "aws_api_key",
+ "description": "Tells the service this field/object has access authorized by an API key.",
+ "locations": ["OBJECT", "FIELD_DEFINITION"],
+ "args": [],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
+ },
+ {
+ "name": "aws_iam",
+ "description": "Tells the service this field/object has access authorized by sigv4 signing.",
+ "locations": ["OBJECT", "FIELD_DEFINITION"],
+ "args": [],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
+ },
+ {
+ "name": "aws_oidc",
+ "description": "Tells the service this field/object has access authorized by an OIDC token.",
+ "locations": ["OBJECT", "FIELD_DEFINITION"],
+ "args": [],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
+ },
+ {
+ "name": "aws_lambda",
+ "description": "Tells the service this field/object has access authorized by a Lambda Authorizer.",
+ "locations": ["OBJECT", "FIELD_DEFINITION"],
+ "args": [],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
+ },
+ {
+ "name": "aws_subscribe",
+ "description": "Tells the service which mutation triggers this subscription.",
+ "locations": ["FIELD_DEFINITION"],
+ "args": [
+ {
+ "name": "mutations",
+ "description": "List of mutations which will trigger this subscription when they are called.",
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ }
+ ],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
+ },
+ {
+ "name": "aws_cognito_user_pools",
+ "description": "Tells the service this field/object has access authorized by a Cognito User Pools token.",
+ "locations": ["OBJECT", "FIELD_DEFINITION"],
+ "args": [
+ {
+ "name": "cognito_groups",
+ "description": "List of cognito user pool groups which have access on this field",
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ }
+ ],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
+ },
+ {
+ "name": "deprecated",
+ "description": null,
+ "locations": ["FIELD_DEFINITION", "ENUM_VALUE"],
+ "args": [
+ {
+ "name": "reason",
+ "description": null,
+ "type": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ },
+ "defaultValue": "\"No longer supported\""
+ }
+ ],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
+ },
+ {
+ "name": "aws_auth",
+ "description": "Directs the schema to enforce authorization on a field",
+ "locations": ["FIELD_DEFINITION"],
+ "args": [
+ {
+ "name": "cognito_groups",
+ "description": "List of cognito user pool groups which have access on this field",
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
+ }
+ },
+ "defaultValue": null
+ }
+ ],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
+ },
+ {
+ "name": "aws_publish",
+ "description": "Tells the service which subscriptions will be published to when this mutation is called. This directive is deprecated use @aws_susbscribe directive instead.",
+ "locations": ["FIELD_DEFINITION"],
+ "args": [
+ {
+ "name": "subscriptions",
+ "description": "List of subscriptions which will be published to when this mutation is called.",
+ "type": {
+ "kind": "LIST",
+ "name": null,
+ "ofType": {
+ "kind": "SCALAR",
+ "name": "String",
+ "ofType": null
}
- ]
+ },
+ "defaultValue": null
+ }
+ ],
+ "onOperation": false,
+ "onFragment": false,
+ "onField": false
}
+ ]
}
-}
\ No newline at end of file
+ }
+}
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-android.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-android.test.ts
index 0636de605..be5417c93 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-android.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-android.test.ts
@@ -1,20 +1,20 @@
-import { createNewProjectDir, DEFAULT_ANDROID_CONFIG } from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_ANDROID_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testAddCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen add tests - Android', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('addCodegenAndroid');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('addCodegenAndroid');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`Adding codegen works as expected`, async () => {
- await testAddCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`Adding codegen works as expected`, async () => {
+ await testAddCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-ios.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-ios.test.ts
index 711b18f41..ea269e988 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-ios.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-ios.test.ts
@@ -1,20 +1,20 @@
-import { createNewProjectDir, DEFAULT_IOS_CONFIG } from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_IOS_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testAddCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen add tests - iOS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('addCodegenIOS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('addCodegenIOS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`Adding codegen works as expected`, async () => {
- await testAddCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`Adding codegen works as expected`, async () => {
+ await testAddCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-js.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-js.test.ts
index 14e457ff0..ebc2f7f53 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-js.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/add-codegen-js.test.ts
@@ -1,84 +1,84 @@
-import {
- createNewProjectDir,
- initProjectWithProfile,
- addCodegen,
- DEFAULT_JS_CONFIG,
- createRandomName,
- addApiWithoutSchema,
- updateApiSchema,
-} from "@aws-amplify/amplify-codegen-e2e-core";
-import { existsSync } from "fs";
+import {
+ createNewProjectDir,
+ initProjectWithProfile,
+ addCodegen,
+ DEFAULT_JS_CONFIG,
+ createRandomName,
+ addApiWithoutSchema,
+ updateApiSchema,
+} from '@aws-amplify/amplify-codegen-e2e-core';
+import { existsSync } from 'fs';
import path from 'path';
import { isNotEmptyDir } from '../utils';
import {
- deleteAmplifyProject,
- testAddCodegen,
- testSetupBeforeAddCodegen,
- getGraphQLConfigFilePath,
- testValidGraphQLConfig,
+ deleteAmplifyProject,
+ testAddCodegen,
+ testSetupBeforeAddCodegen,
+ getGraphQLConfigFilePath,
+ testValidGraphQLConfig,
} from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen add tests - JS', () => {
- let projectRoot: string;
- let config = DEFAULT_JS_CONFIG;
+ let projectRoot: string;
+ let config = DEFAULT_JS_CONFIG;
+
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('addCodegenJS');
+ });
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('addCodegenJS');
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ it(`Adding codegen without API gives appropriate message`, async () => {
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { ...config });
- it(`Adding codegen without API gives appropriate message`, async () => {
- // init project and add API category
- await initProjectWithProfile(projectRoot, { ...config });
+ const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
- const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
+ // add codegen without API gives appropriate message
+ const settings = { isAPINotAdded: true, ...config };
+ await expect(addCodegen(projectRoot, settings)).resolves.not.toThrow();
- // add codegen without API gives appropriate message
- const settings = { isAPINotAdded: true, ...config };
- await expect(addCodegen(projectRoot, settings)).resolves.not.toThrow();
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
+ // GraphQL statements are not generated
+ expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(false);
+ // graphql configuration should not be added
+ expect(existsSync(getGraphQLConfigFilePath(projectRoot))).toBe(false);
+ });
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
- // GraphQL statements are not generated
- expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(false);
- // graphql configuration should not be added
- expect(existsSync(getGraphQLConfigFilePath(projectRoot))).toBe(false);
- });
+ it(`Adding codegen twice gives appropriate message`, async () => {
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { ...config });
+ const projectName = createRandomName();
+ await addApiWithoutSchema(projectRoot, { apiName: projectName });
+ await updateApiSchema(projectRoot, projectName, schema);
- it(`Adding codegen twice gives appropriate message`, async () => {
- // init project and add API category
- await initProjectWithProfile(projectRoot, { ...config });
- const projectName = createRandomName();
- await addApiWithoutSchema(projectRoot, { apiName: projectName });
- await updateApiSchema(projectRoot, projectName, schema);
+ const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
- const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
+ // adding codegen succeeds and generates a config file
+ await expect(addCodegen(projectRoot, { ...config })).resolves.not.toThrow();
+ expect(existsSync(getGraphQLConfigFilePath(projectRoot))).toBe(true);
- // adding codegen succeeds and generates a config file
- await expect(addCodegen(projectRoot, { ...config })).resolves.not.toThrow();
- expect(existsSync(getGraphQLConfigFilePath(projectRoot))).toBe(true);
-
- // adding codegen again gives appropriate message
- const settings = { isCodegenAdded: true, ...config };
- await expect(addCodegen(projectRoot, settings)).resolves.not.toThrow();
+ // adding codegen again gives appropriate message
+ const settings = { isCodegenAdded: true, ...config };
+ await expect(addCodegen(projectRoot, settings)).resolves.not.toThrow();
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
- // previously generated files should still exist
- expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
- testValidGraphQLConfig(projectRoot, config);
- });
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
+ // previously generated files should still exist
+ expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
+ testValidGraphQLConfig(projectRoot, config);
+ });
- it(`Adding codegen works as expected`, async () => {
- await testAddCodegen(config, projectRoot, schema);
- });
+ it(`Adding codegen works as expected`, async () => {
+ await testAddCodegen(config, projectRoot, schema);
+ });
- it(`supports add codegen with redundant region parameter`, async () => {
- await testAddCodegen(config, projectRoot, schema, ['--region', 'us-fake-1']);
- });
+ it(`supports add codegen with redundant region parameter`, async () => {
+ await testAddCodegen(config, projectRoot, schema, ['--region', 'us-fake-1']);
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/handlers/mutation.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/handlers/mutation.ts
index e4f707b85..09f327ccf 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/handlers/mutation.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/handlers/mutation.ts
@@ -1,6 +1,6 @@
-import type { Schema } from '../resource'
+import type { Schema } from '../resource';
-export const handler: Schema["echoMutation"]["functionHandler"] = async (event, context) => {
+export const handler: Schema['echoMutation']['functionHandler'] = async (event, context) => {
return {
id: 'todo1',
content: `Echoing content: ${event.arguments.requiredContent}`,
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/handlers/query.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/handlers/query.ts
index f7eda1ac1..616af15ec 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/handlers/query.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/handlers/query.ts
@@ -1,9 +1,9 @@
-import type { Schema } from '../resource'
+import type { Schema } from '../resource';
-export const handler: Schema["echoQuery"]["functionHandler"] = async (event, context) => {
+export const handler: Schema['echoQuery']['functionHandler'] = async (event, context) => {
const start = performance.now();
return {
content: `Echoing content: ${event.arguments.content}`,
- executionDuration: performance.now() - start
+ executionDuration: performance.now() - start,
};
};
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/resource.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/resource.ts
index 648d5993c..e96029ecf 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/resource.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/backends/graphql-generator-gen2/resource.ts
@@ -1,10 +1,10 @@
import { type ClientSchema, a, defineData, defineFunction } from '@aws-amplify/backend';
const echoQueryHandler = defineFunction({
- entry: './handlers/query.ts'
+ entry: './handlers/query.ts',
});
const echoMutationHandler = defineFunction({
- entry: './handlers/mutation.ts'
+ entry: './handlers/mutation.ts',
});
const schema = a.schema({
@@ -16,14 +16,11 @@ const schema = a.schema({
})
.authorization((allow) => [allow.guest()]),
// Enum Type
- Status: a.enum([
- 'PROGRESS',
- 'COMPLETED',
- ]),
+ Status: a.enum(['PROGRESS', 'COMPLETED']),
// Non model type
EchoResponse: a.customType({
content: a.string(),
- executionDuration: a.float()
+ executionDuration: a.float(),
}),
// Custom query and mutation
echoQuery: a
@@ -33,15 +30,15 @@ const schema = a.schema({
status: a.enum(['PROGRESS', 'COMPLETED']),
})
.returns(a.ref('EchoResponse'))
- .authorization(allow => [allow.authenticated()])
+ .authorization((allow) => [allow.authenticated()])
.handler(a.handler.function(echoQueryHandler)),
echoMutation: a
.mutation()
.arguments({
- requiredContent: a.string().required()
+ requiredContent: a.string().required(),
})
.returns(a.ref('Todo').required())
- .authorization(allow => [allow.authenticated()])
+ .authorization((allow) => [allow.authenticated()])
.handler(a.handler.function(echoMutationHandler)),
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/codegen-matrix.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/codegen-matrix.test.ts
index e58b12c04..eea843b34 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/codegen-matrix.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/codegen-matrix.test.ts
@@ -1,5 +1,19 @@
-import { DEFAULT_JS_CONFIG, createNewProjectDir, initProjectWithProfile, createRandomName, addApiWithoutSchema, updateApiSchema, apiGqlCompile, removeCodegen, amplifyConfigureProjectInfo, AmplifyFrontend, DEFAULT_FLUTTER_CONFIG, DEFAULT_IOS_CONFIG, DEFAULT_ANDROID_CONFIG } from "@aws-amplify/amplify-codegen-e2e-core";
-import { CodegenMatrixTestProps, deleteAmplifyProject, testAddCodegenMatrix } from "../codegen-tests-base";
+import {
+ DEFAULT_JS_CONFIG,
+ createNewProjectDir,
+ initProjectWithProfile,
+ createRandomName,
+ addApiWithoutSchema,
+ updateApiSchema,
+ apiGqlCompile,
+ removeCodegen,
+ amplifyConfigureProjectInfo,
+ AmplifyFrontend,
+ DEFAULT_FLUTTER_CONFIG,
+ DEFAULT_IOS_CONFIG,
+ DEFAULT_ANDROID_CONFIG,
+} from '@aws-amplify/amplify-codegen-e2e-core';
+import { CodegenMatrixTestProps, deleteAmplifyProject, testAddCodegenMatrix } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
@@ -16,15 +30,13 @@ describe('JS codegen matrix test', () => {
await updateApiSchema(projectRoot, projectName, schema);
await apiGqlCompile(projectRoot);
});
- beforeEach(async () => {
-
- });
+ beforeEach(async () => {});
afterEach(async () => {
await removeCodegen(projectRoot);
- await amplifyConfigureProjectInfo({ cwd: projectRoot, frontendType: 'flutter'} )
+ await amplifyConfigureProjectInfo({ cwd: projectRoot, frontendType: 'flutter' });
});
afterAll(async () => {
- await deleteAmplifyProject(projectRoot);
+ await deleteAmplifyProject(projectRoot);
});
it('Flutter - no statements or types', async () => {
@@ -32,7 +44,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_FLUTTER_CONFIG,
isStatementGenerated: false,
isTypeGenerated: false,
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
@@ -40,21 +52,21 @@ describe('JS codegen matrix test', () => {
config = {
...DEFAULT_ANDROID_CONFIG,
isTypeGenerated: false,
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('iOS - single file path as type name', async () => {
config = {
...DEFAULT_IOS_CONFIG,
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('iOS - folder as type name', async () => {
config = {
...DEFAULT_IOS_CONFIG,
typeFileName: 'apiType', // directory name
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
@@ -63,7 +75,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'angular',
codegenTarget: 'angular',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - angular - typescript', async () => {
@@ -71,7 +83,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'angular',
codegenTarget: 'typescript',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
@@ -80,7 +92,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'ionic',
codegenTarget: 'angular',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - ionic - typescript', async () => {
@@ -88,7 +100,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'ionic',
codegenTarget: 'typescript',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
@@ -96,21 +108,21 @@ describe('JS codegen matrix test', () => {
config = {
...DEFAULT_JS_CONFIG,
isTypeGenerated: false,
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - none - typescript', async () => {
config = {
...DEFAULT_JS_CONFIG,
codegenTarget: 'typescript',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - none - flow', async () => {
config = {
...DEFAULT_JS_CONFIG,
codegenTarget: 'flow',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
@@ -120,7 +132,7 @@ describe('JS codegen matrix test', () => {
framework: 'react',
codegenTarget: 'javascript',
isTypeGenerated: false,
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - react - typescript', async () => {
@@ -128,7 +140,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'react',
codegenTarget: 'typescript',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - react - flow', async () => {
@@ -136,7 +148,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'react',
codegenTarget: 'flow',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
@@ -146,7 +158,7 @@ describe('JS codegen matrix test', () => {
framework: 'react-native',
codegenTarget: 'javascript',
isTypeGenerated: false,
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - react native - typescript', async () => {
@@ -154,7 +166,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'react-native',
codegenTarget: 'typescript',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - react native - flow', async () => {
@@ -162,7 +174,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'react-native',
codegenTarget: 'flow',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
@@ -172,7 +184,7 @@ describe('JS codegen matrix test', () => {
framework: 'ember',
codegenTarget: 'javascript',
isTypeGenerated: false,
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - ember - typescript', async () => {
@@ -180,7 +192,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'ember',
codegenTarget: 'typescript',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - ember - flow', async () => {
@@ -188,7 +200,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'ember',
codegenTarget: 'flow',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
@@ -198,7 +210,7 @@ describe('JS codegen matrix test', () => {
framework: 'vue',
codegenTarget: 'javascript',
isTypeGenerated: false,
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - vue - typescript', async () => {
@@ -206,7 +218,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'vue',
codegenTarget: 'typescript',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
it('JavaScript - vue - flow', async () => {
@@ -214,7 +226,7 @@ describe('JS codegen matrix test', () => {
...DEFAULT_JS_CONFIG,
framework: 'vue',
codegenTarget: 'flow',
- }
+ };
await testAddCodegenMatrix(config, projectRoot);
});
-});
\ No newline at end of file
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-android.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-android.test.ts
index d1126fb72..a2c9e9bb4 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-android.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-android.test.ts
@@ -1,20 +1,20 @@
-import { createNewProjectDir, DEFAULT_ANDROID_CONFIG } from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_ANDROID_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testConfigureCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen configure tests - Android', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('configureCodegenAndroid');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('configureCodegenAndroid');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`Updating codegen configuration works as expected`, async () => {
- await testConfigureCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`Updating codegen configuration works as expected`, async () => {
+ await testConfigureCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-ios.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-ios.test.ts
index 0f9f5d3fe..bc97a4f36 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-ios.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-ios.test.ts
@@ -1,20 +1,20 @@
-import { createNewProjectDir, DEFAULT_IOS_CONFIG } from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_IOS_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testConfigureCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen configure tests - iOS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('configureCodegenIOS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('configureCodegenIOS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`Updating codegen configuration works as expected`, async () => {
- await testConfigureCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`Updating codegen configuration works as expected`, async () => {
+ await testConfigureCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-js.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-js.test.ts
index 36ce23b9e..67bb0176e 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-js.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/configure-codegen-js.test.ts
@@ -1,20 +1,20 @@
-import { createNewProjectDir, DEFAULT_JS_CONFIG } from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_JS_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testConfigureCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen configure tests - JS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('configureCodegenJS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('configureCodegenJS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`Updating codegen configuration works as expected`, async () => {
- await testConfigureCodegen(DEFAULT_JS_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`Updating codegen configuration works as expected`, async () => {
+ await testConfigureCodegen(DEFAULT_JS_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-android.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-android.test.ts
index d00116deb..a4071ee8d 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-android.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-android.test.ts
@@ -5,21 +5,21 @@ import * as path from 'path';
const schema = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Datastore Modelgen tests - Android', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('datastoreModelgenAndroid');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('datastoreModelgenAndroid');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`should generate files at desired location and not delete src files`, async () => {
- await testCodegenModels(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testCodegenModels(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
+ });
- it('Should generate files at overridden output path', async () => {
- await testCodegenModels(DEFAULT_ANDROID_CONFIG, projectRoot, schema, path.join('app', 'src', 'main', 'guava'));
- });
+ it('Should generate files at overridden output path', async () => {
+ await testCodegenModels(DEFAULT_ANDROID_CONFIG, projectRoot, schema, path.join('app', 'src', 'main', 'guava'));
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-flutter.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-flutter.test.ts
index efcb54cc8..c79646094 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-flutter.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-flutter.test.ts
@@ -5,19 +5,19 @@ import * as path from 'path';
const schema = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Datastore Modelgen tests - Flutter', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('datastoreModelgenFlutter');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('datastoreModelgenFlutter');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`should generate files at desired location and not delete src files`, async () => {
- await testCodegenModels(DEFAULT_FLUTTER_CONFIG, projectRoot, schema);
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testCodegenModels(DEFAULT_FLUTTER_CONFIG, projectRoot, schema);
+ });
it(`should generate files at overridden location`, async () => {
await testCodegenModels(DEFAULT_FLUTTER_CONFIG, projectRoot, schema, path.join('lib', 'blueprints'));
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-ios.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-ios.test.ts
index 03fa87968..df815921a 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-ios.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-ios.test.ts
@@ -5,21 +5,21 @@ import * as path from 'path';
const schema = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Datastore Modelgen tests - iOS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('datastoreModelgenIOS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('datastoreModelgenIOS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`should generate files at desired location and not delete src files`, async () => {
- await testCodegenModels(DEFAULT_IOS_CONFIG, projectRoot, schema);
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testCodegenModels(DEFAULT_IOS_CONFIG, projectRoot, schema);
+ });
- it(`should generate files at overridden location`, async () => {
- await testCodegenModels(DEFAULT_IOS_CONFIG, projectRoot, schema, path.join('amplification', 'manufactured', 'models'));
- });
+ it(`should generate files at overridden location`, async () => {
+ await testCodegenModels(DEFAULT_IOS_CONFIG, projectRoot, schema, path.join('amplification', 'manufactured', 'models'));
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-js.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-js.test.ts
index 9b617cd5b..04a0d72c0 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-js.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/datastore-modelgen-js.test.ts
@@ -5,21 +5,21 @@ import * as path from 'path';
const schema = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Datastore Modelgen tests - JS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('datastoreModelgenJS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('datastoreModelgenJS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`should generate files at desired location and not delete src files`, async () => {
- await testCodegenModels(DEFAULT_JS_CONFIG, projectRoot, schema);
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testCodegenModels(DEFAULT_JS_CONFIG, projectRoot, schema);
+ });
- it(`should generate files at desired location and not delete src files`, async () => {
- await testCodegenModels(DEFAULT_JS_CONFIG, projectRoot, schema, path.join('src', 'backmodels'));
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testCodegenModels(DEFAULT_JS_CONFIG, projectRoot, schema, path.join('src', 'backmodels'));
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/env-codegen.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/env-codegen.test.ts
index 2d6da90ac..c6b293588 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/env-codegen.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/env-codegen.test.ts
@@ -1,14 +1,14 @@
-import {
- createNewProjectDir,
+import {
+ createNewProjectDir,
deleteProjectDir,
deleteProject,
initJSProjectWithProfile,
amplifyPush,
generateModels,
addApiWithoutSchema,
- updateApiSchema
-} from "@aws-amplify/amplify-codegen-e2e-core";
-import { addEnvironment, checkoutEnvironment } from "../environment/env";
+ updateApiSchema,
+} from '@aws-amplify/amplify-codegen-e2e-core';
+import { addEnvironment, checkoutEnvironment } from '../environment/env';
const schema = 'simple_model.graphql';
const schemaWithError = 'modelgen/model_gen_schema_with_errors.graphql';
const apiName = 'envtest';
@@ -34,10 +34,10 @@ describe('env codegen tests', () => {
//create new envb
await addEnvironment(projectRoot, { envName: 'envb' });
//update schema to a invalid one in envb and generate models
- updateApiSchema(projectRoot, apiName, schemaWithError)
+ updateApiSchema(projectRoot, apiName, schemaWithError);
await expect(generateModels(projectRoot, undefined, { errMessage: 'Unknown type' }));
//checkout back to enva and generate models
await checkoutEnvironment(projectRoot, { envName: 'enva', withRestore: true });
await expect(generateModels(projectRoot)).resolves.not.toThrow();
});
-});
\ No newline at end of file
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-android.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-android.test.ts
index 92df3d57e..b9532b354 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-android.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-android.test.ts
@@ -1,23 +1,20 @@
-import {
- createNewProjectDir,
- DEFAULT_ANDROID_CONFIG,
- } from "@aws-amplify/amplify-codegen-e2e-core";
- import { deleteAmplifyProject, testGraphQLCodegen } from '../codegen-tests-base';
-
- const schema = 'simple_model.graphql';
-
- describe('GraphQL codegen tests - Android', () => {
- let projectRoot: string;
-
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('graphqlCodegenAndroid');
- });
-
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
-
- it(`Should generate files in correct place and not delete src files in Android project`, async() => {
- await testGraphQLCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema)
- });
-});
\ No newline at end of file
+import { createNewProjectDir, DEFAULT_ANDROID_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
+import { deleteAmplifyProject, testGraphQLCodegen } from '../codegen-tests-base';
+
+const schema = 'simple_model.graphql';
+
+describe('GraphQL codegen tests - Android', () => {
+ let projectRoot: string;
+
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('graphqlCodegenAndroid');
+ });
+
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
+
+ it(`Should generate files in correct place and not delete src files in Android project`, async () => {
+ await testGraphQLCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-ios.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-ios.test.ts
index ddd0693c6..b685ff5c5 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-ios.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-ios.test.ts
@@ -1,23 +1,20 @@
-import {
- createNewProjectDir,
- DEFAULT_IOS_CONFIG,
- } from "@aws-amplify/amplify-codegen-e2e-core";
- import { deleteAmplifyProject, testGraphQLCodegen } from '../codegen-tests-base';
-
- const schema = 'simple_model.graphql';
-
- describe('GraphQL codegen tests - iOS', () => {
- let projectRoot: string;
-
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('graphqlCodegenIOS');
- });
-
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
-
- it(`Should generate files in correct place and not delete src files in iOS project`, async() => {
- await testGraphQLCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema)
- });
-});
\ No newline at end of file
+import { createNewProjectDir, DEFAULT_IOS_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
+import { deleteAmplifyProject, testGraphQLCodegen } from '../codegen-tests-base';
+
+const schema = 'simple_model.graphql';
+
+describe('GraphQL codegen tests - iOS', () => {
+ let projectRoot: string;
+
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('graphqlCodegenIOS');
+ });
+
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
+
+ it(`Should generate files in correct place and not delete src files in iOS project`, async () => {
+ await testGraphQLCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-js.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-js.test.ts
index 2061dc552..2c98ea32b 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-js.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-codegen-js.test.ts
@@ -1,23 +1,20 @@
-import {
- createNewProjectDir,
- DEFAULT_JS_CONFIG,
- } from "@aws-amplify/amplify-codegen-e2e-core";
- import { deleteAmplifyProject, testGraphQLCodegen } from '../codegen-tests-base';
-
- const schema = 'simple_model.graphql';
-
- describe('GraphQL codegen tests - JS', () => {
- let projectRoot: string;
-
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('graphqlCodegenJS');
- });
-
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
-
- it(`Should generate files in correct place and not delete src files in JS project`, async() => {
- await testGraphQLCodegen(DEFAULT_JS_CONFIG, projectRoot, schema)
- });
-});
\ No newline at end of file
+import { createNewProjectDir, DEFAULT_JS_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
+import { deleteAmplifyProject, testGraphQLCodegen } from '../codegen-tests-base';
+
+const schema = 'simple_model.graphql';
+
+describe('GraphQL codegen tests - JS', () => {
+ let projectRoot: string;
+
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('graphqlCodegenJS');
+ });
+
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
+
+ it(`Should generate files in correct place and not delete src files in JS project`, async () => {
+ await testGraphQLCodegen(DEFAULT_JS_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-generator-gen2.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-generator-gen2.test.ts
index 7902d4f63..c2818d863 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-generator-gen2.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/graphql-generator-gen2.test.ts
@@ -1,6 +1,16 @@
import * as path from 'path';
-import { createNewProjectDir, deleteProjectDir } from "@aws-amplify/amplify-codegen-e2e-core";
-import { GraphqlCodegenConfig, IntrospectionCodegenConfig, ModelgenConfig, deleteSandbox, generateForms, generateOutputs, initGen2Project, sandboxDeploy, testGraphqlClientCodegen } from "../gen2-codegen-tests-base/";
+import { createNewProjectDir, deleteProjectDir } from '@aws-amplify/amplify-codegen-e2e-core';
+import {
+ GraphqlCodegenConfig,
+ IntrospectionCodegenConfig,
+ ModelgenConfig,
+ deleteSandbox,
+ generateForms,
+ generateOutputs,
+ initGen2Project,
+ sandboxDeploy,
+ testGraphqlClientCodegen,
+} from '../gen2-codegen-tests-base/';
describe('GraphQL generator for Gen2 e2e tests', () => {
let projRoot: string;
@@ -9,7 +19,7 @@ describe('GraphQL generator for Gen2 e2e tests', () => {
beforeAll(async () => {
projFolderName = 'graphqlGeneratorGen2';
projRoot = await createNewProjectDir(projFolderName);
- const template = path.resolve(path.join(__dirname, 'backends', 'graphql-generator-gen2'))
+ const template = path.resolve(path.join(__dirname, 'backends', 'graphql-generator-gen2'));
await initGen2Project(projRoot, template);
await sandboxDeploy(projRoot);
});
@@ -28,20 +38,18 @@ describe('GraphQL generator for Gen2 e2e tests', () => {
});
describe('Graphql client codegen', () => {
// introspection
- const introspectionCodegenConfigs: IntrospectionCodegenConfig[] = [
- { outDir: 'codegen', format: 'introspection' }
- ];
- introspectionCodegenConfigs.forEach(config => {
+ const introspectionCodegenConfigs: IntrospectionCodegenConfig[] = [{ outDir: 'codegen', format: 'introspection' }];
+ introspectionCodegenConfigs.forEach((config) => {
it(`should not throw error when generating GraphQL client code in format ${config.format}`, async () => {
await testGraphqlClientCodegen(projRoot, config);
});
});
// modelgen
- const modelTargets = ['java', 'swift', 'javascript', 'typescript', 'dart']
- const modelgenConfigs: ModelgenConfig[] = modelTargets.map(target => {
+ const modelTargets = ['java', 'swift', 'javascript', 'typescript', 'dart'];
+ const modelgenConfigs: ModelgenConfig[] = modelTargets.map((target) => {
return { outDir: 'codegen', format: 'modelgen', modelTarget: target };
- })
- modelgenConfigs.forEach(config => {
+ });
+ modelgenConfigs.forEach((config) => {
it(`should not throw error when generating GraphQL client code in format ${config.format} with target ${config.modelTarget}`, async () => {
await testGraphqlClientCodegen(projRoot, config);
});
@@ -49,17 +57,21 @@ describe('GraphQL generator for Gen2 e2e tests', () => {
// graphql codegen
const statementTargets = ['javascript', 'graphql', 'flow', 'typescript', 'angular'];
const typeTargets = ['json', 'swift', 'typescript', 'flow', 'scala', 'flow-modern', 'angular'];
- const typeTargetConfigs = typeTargets.map(tt => { return { outDir: 'codegen', format: 'graphql-codegen', typeTarget: tt }});
- const graphqlCodegenConfigs: GraphqlCodegenConfig[] = statementTargets.map(st => {
- return typeTargetConfigs.map(config => {
- return { ...config, statementTarget: st } as GraphqlCodegenConfig
- });
- }).flat();
- graphqlCodegenConfigs.forEach(config => {
+ const typeTargetConfigs = typeTargets.map((tt) => {
+ return { outDir: 'codegen', format: 'graphql-codegen', typeTarget: tt };
+ });
+ const graphqlCodegenConfigs: GraphqlCodegenConfig[] = statementTargets
+ .map((st) => {
+ return typeTargetConfigs.map((config) => {
+ return { ...config, statementTarget: st } as GraphqlCodegenConfig;
+ });
+ })
+ .flat();
+ graphqlCodegenConfigs.forEach((config) => {
// TODO: skip these tests as it will fail due to the duplicate graphql module. Will enable them once the issue is resolved
it.skip(`should not throw error when generating GraphQL client code in format ${config.format} with type ${config.typeTarget} and statement ${config.statementTarget}`, async () => {
await testGraphqlClientCodegen(projRoot, config);
});
- })
- })
-});
\ No newline at end of file
+ });
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/model-introspection-codegen.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/model-introspection-codegen.test.ts
index 0b3bdfade..e1762a1c5 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/model-introspection-codegen.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/model-introspection-codegen.test.ts
@@ -1,67 +1,72 @@
-import { addApiWithoutSchema, createNewProjectDir, generateModelIntrospection, initJSProjectWithProfile, updateApiSchema } from "@aws-amplify/amplify-codegen-e2e-core";
+import {
+ addApiWithoutSchema,
+ createNewProjectDir,
+ generateModelIntrospection,
+ initJSProjectWithProfile,
+ updateApiSchema,
+} from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject } from '../codegen-tests-base';
-import { isNotEmptyDir } from "../utils";
+import { isNotEmptyDir } from '../utils';
import { join } from 'path';
const schema = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Model Introspection Codegen test', () => {
- let projectRoot: string;
- const apiName = 'modelintrospection';
+ let projectRoot: string;
+ const apiName = 'modelintrospection';
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('modelIntrospection');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('modelIntrospection');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`should generate files at desired location and not delete src files`, async () => {
- // init project and add API category
- await initJSProjectWithProfile(projectRoot);
- await addApiWithoutSchema(projectRoot, { apiName });
- await updateApiSchema(projectRoot, apiName, schema);
- const outputDir = 'output';
- //generate introspection schema
- await expect(generateModelIntrospection(projectRoot, { outputDir })).resolves.not.toThrow();
- // Model introspection is generated at correct location
- expect(isNotEmptyDir(join(projectRoot, outputDir))).toBe(true);
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ // init project and add API category
+ await initJSProjectWithProfile(projectRoot);
+ await addApiWithoutSchema(projectRoot, { apiName });
+ await updateApiSchema(projectRoot, apiName, schema);
+ const outputDir = 'output';
+ //generate introspection schema
+ await expect(generateModelIntrospection(projectRoot, { outputDir })).resolves.not.toThrow();
+ // Model introspection is generated at correct location
+ expect(isNotEmptyDir(join(projectRoot, outputDir))).toBe(true);
+ });
- it('should throw error when the output directory is not defined in the command', async () => {
- // init project and add API category
- await initJSProjectWithProfile(projectRoot);
- await addApiWithoutSchema(projectRoot, { apiName });
- await updateApiSchema(projectRoot, apiName, schema);
- //generate introspection schema
- await generateModelIntrospection(projectRoot, { errMessage: 'Expected --output-dir flag to be set'});
- });
+ it('should throw error when the output directory is not defined in the command', async () => {
+ // init project and add API category
+ await initJSProjectWithProfile(projectRoot);
+ await addApiWithoutSchema(projectRoot, { apiName });
+ await updateApiSchema(projectRoot, apiName, schema);
+ //generate introspection schema
+ await generateModelIntrospection(projectRoot, { errMessage: 'Expected --output-dir flag to be set' });
+ });
- it('should throw error if the GraphQL schema is invalid', async () => {
- const invalidSchema = 'modelgen/model_gen_schema_with_errors.graphql';
- // init project and add API category
- await initJSProjectWithProfile(projectRoot);
- await addApiWithoutSchema(projectRoot, { apiName });
- await updateApiSchema(projectRoot, apiName, invalidSchema);
- const outputDir = 'output';
- //generate introspection schema
- await generateModelIntrospection(projectRoot,{ outputDir, errMessage: 'Unknown type'});
- });
+ it('should throw error if the GraphQL schema is invalid', async () => {
+ const invalidSchema = 'modelgen/model_gen_schema_with_errors.graphql';
+ // init project and add API category
+ await initJSProjectWithProfile(projectRoot);
+ await addApiWithoutSchema(projectRoot, { apiName });
+ await updateApiSchema(projectRoot, apiName, invalidSchema);
+ const outputDir = 'output';
+ //generate introspection schema
+ await generateModelIntrospection(projectRoot, { outputDir, errMessage: 'Unknown type' });
+ });
- it(`should handle a schema with connected PK`, async () => {
- const schemaName = 'modelgen/schema_with_connected_pk.graphql';
+ it(`should handle a schema with connected PK`, async () => {
+ const schemaName = 'modelgen/schema_with_connected_pk.graphql';
- // init project and add API category
- await initJSProjectWithProfile(projectRoot);
- await addApiWithoutSchema(projectRoot, { apiName });
- await updateApiSchema(projectRoot, apiName, schemaName);
+ // init project and add API category
+ await initJSProjectWithProfile(projectRoot);
+ await addApiWithoutSchema(projectRoot, { apiName });
+ await updateApiSchema(projectRoot, apiName, schemaName);
- const outputDir = 'output';
- //generate introspection schema
- await expect(generateModelIntrospection(projectRoot, { outputDir })).resolves.not.toThrow();
- // Model introspection is generated at correct location
- expect(isNotEmptyDir(join(projectRoot, outputDir))).toBe(true);
- });
+ const outputDir = 'output';
+ //generate introspection schema
+ await expect(generateModelIntrospection(projectRoot, { outputDir })).resolves.not.toThrow();
+ // Model introspection is generated at correct location
+ expect(isNotEmptyDir(join(projectRoot, outputDir))).toBe(true);
+ });
});
-
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/pull-codegen.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/pull-codegen.test.ts
index 31dc3e88f..0573b7b12 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/pull-codegen.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/pull-codegen.test.ts
@@ -71,7 +71,7 @@ describe('Amplify pull in amplify app with codegen tests', () => {
deleteProjectDir(emptyProjectRoot);
});
- frontendConfigs.forEach(config => {
+ frontendConfigs.forEach((config) => {
// skip ios test on windows
(isWindows() && config.frontendType === 'ios' ? it.skip : it)(
`should generate models and do not delete user files by amplify pull in an empty folder of ${config.frontendType} app`,
@@ -117,7 +117,7 @@ describe('Amplify pull in sandbox app with codegen tests', () => {
deleteProjectDir(projectRoot);
});
- frontendConfigs.forEach(config => {
+ frontendConfigs.forEach((config) => {
it(`should pull sandbox, download schema and generate models without deleting user files in ${config.frontendType} project`, async () => {
//generate pre existing user file
const userSourceCodePath = generateSourceCode(projectRoot, config.srcDir);
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-admin-modelgen.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-admin-modelgen.test.ts
index 5c7bedb1d..76d0b88ae 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-admin-modelgen.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-admin-modelgen.test.ts
@@ -1,5 +1,5 @@
-import { DEFAULT_JS_CONFIG, createNewProjectDir } from "@aws-amplify/amplify-codegen-e2e-core";
-import { deleteAmplifyProject, testPushAdminModelgen, testPushCodegen } from "../codegen-tests-base";
+import { DEFAULT_JS_CONFIG, createNewProjectDir } from '@aws-amplify/amplify-codegen-e2e-core';
+import { deleteAmplifyProject, testPushAdminModelgen, testPushCodegen } from '../codegen-tests-base';
const schema = 'admin-modelgen.graphql';
@@ -16,4 +16,4 @@ describe('Amplify push with codegen tests - admin modelgen', () => {
it(`should not throw error for executing the admin modelgen step required by studio CMS usage post push given the schema with input, union and interface types`, async () => {
await testPushAdminModelgen(DEFAULT_JS_CONFIG, projectRoot, schema);
});
-});
\ No newline at end of file
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-android.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-android.test.ts
index c1767a761..20f66d30a 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-android.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-android.test.ts
@@ -1,22 +1,19 @@
-import {
- createNewProjectDir,
- DEFAULT_ANDROID_CONFIG
-} from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_ANDROID_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testPushCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('Amplify push with codegen tests - Android', () => {
- let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('pushCodegenAndroid');
- });
+ let projectRoot: string;
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('pushCodegenAndroid');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`should prompt codegen add/update and not delete user files`, async () => {
- await testPushCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`should prompt codegen add/update and not delete user files`, async () => {
+ await testPushCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-ios.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-ios.test.ts
index ed1657c5a..cf04e6f00 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-ios.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-ios.test.ts
@@ -1,22 +1,19 @@
-import {
- createNewProjectDir,
- DEFAULT_IOS_CONFIG
-} from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_IOS_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testPushCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('Amplify push with codegen tests - iOS', () => {
- let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('pushCodegenIOS');
- });
+ let projectRoot: string;
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('pushCodegenIOS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`should prompt codegen add/update and not delete user files`, async () => {
- await testPushCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`should prompt codegen add/update and not delete user files`, async () => {
+ await testPushCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-js.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-js.test.ts
index f8bb88930..2b3737fb8 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-js.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/push-codegen-js.test.ts
@@ -1,7 +1,4 @@
-import {
- createNewProjectDir,
- DEFAULT_JS_CONFIG
-} from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_JS_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testPushCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
@@ -13,10 +10,10 @@ describe('Amplify push with codegen tests - JS', () => {
});
afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
+ await deleteAmplifyProject(projectRoot);
});
it(`should prompt codegen add/update and not delete user files`, async () => {
await testPushCodegen(DEFAULT_JS_CONFIG, projectRoot, schema);
});
-});
\ No newline at end of file
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-android.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-android.test.ts
index b0477ec23..287d5569e 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-android.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-android.test.ts
@@ -1,20 +1,20 @@
-import { createNewProjectDir, DEFAULT_ANDROID_CONFIG } from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_ANDROID_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testRemoveCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen remove tests - Android', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('removeCodegenAndroid');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('removeCodegenAndroid');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`Does not delete files during codegen remove`, async () => {
- await testRemoveCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`Does not delete files during codegen remove`, async () => {
+ await testRemoveCodegen(DEFAULT_ANDROID_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-ios.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-ios.test.ts
index b0a978f82..4bcbcb532 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-ios.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-ios.test.ts
@@ -1,20 +1,20 @@
-import { createNewProjectDir, DEFAULT_IOS_CONFIG } from "@aws-amplify/amplify-codegen-e2e-core";
+import { createNewProjectDir, DEFAULT_IOS_CONFIG } from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testRemoveCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen remove tests - iOS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('removeCodegenIOS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('removeCodegenIOS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`Does not delete files during codegen remove`, async () => {
- await testRemoveCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ it(`Does not delete files during codegen remove`, async () => {
+ await testRemoveCodegen(DEFAULT_IOS_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-js.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-js.test.ts
index a5511cf14..b7305d618 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-js.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/remove-codegen-js.test.ts
@@ -1,39 +1,39 @@
-import {
- createNewProjectDir,
- DEFAULT_JS_CONFIG,
- removeCodegen,
- initProjectWithProfile,
- addApiWithoutSchema,
- updateApiSchema,
- createRandomName
-} from "@aws-amplify/amplify-codegen-e2e-core";
+import {
+ createNewProjectDir,
+ DEFAULT_JS_CONFIG,
+ removeCodegen,
+ initProjectWithProfile,
+ addApiWithoutSchema,
+ updateApiSchema,
+ createRandomName,
+} from '@aws-amplify/amplify-codegen-e2e-core';
import { deleteAmplifyProject, testRemoveCodegen } from '../codegen-tests-base';
const schema = 'simple_model.graphql';
describe('codegen remove tests - JS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('removeCodegenJS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('removeCodegenJS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`Give appropriate message during remove when codegen is not added in JS project`, async () => {
- // init project and add API category
- await initProjectWithProfile(projectRoot, DEFAULT_JS_CONFIG);
- const projectName = createRandomName();
- await addApiWithoutSchema(projectRoot, { apiName: projectName });
- await updateApiSchema(projectRoot, projectName, schema);
-
- // remove command should give expected message
- await expect(removeCodegen(projectRoot, false)).resolves.not.toThrow();
- });
+ it(`Give appropriate message during remove when codegen is not added in JS project`, async () => {
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, DEFAULT_JS_CONFIG);
+ const projectName = createRandomName();
+ await addApiWithoutSchema(projectRoot, { apiName: projectName });
+ await updateApiSchema(projectRoot, projectName, schema);
- it(`Does not delete files during codegen remove`, async () => {
- await testRemoveCodegen(DEFAULT_JS_CONFIG, projectRoot, schema);
- });
-});
\ No newline at end of file
+ // remove command should give expected message
+ await expect(removeCodegen(projectRoot, false)).resolves.not.toThrow();
+ });
+
+ it(`Does not delete files during codegen remove`, async () => {
+ await testRemoveCodegen(DEFAULT_JS_CONFIG, projectRoot, schema);
+ });
+});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-codegen-js.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-codegen-js.test.ts
index 0cba9a60a..66b987965 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-codegen-js.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-codegen-js.test.ts
@@ -1,114 +1,119 @@
-import { createNewProjectDir, DEFAULT_JS_CONFIG, generateStatementsAndTypes, AmplifyFrontendConfig } from '@aws-amplify/amplify-codegen-e2e-core';
+import {
+ createNewProjectDir,
+ DEFAULT_JS_CONFIG,
+ generateStatementsAndTypes,
+ AmplifyFrontendConfig,
+} from '@aws-amplify/amplify-codegen-e2e-core';
import path from 'path';
import { deleteAmplifyProject, testAddCodegenUninitialized } from '../codegen-tests-base';
-import { rmSync } from "fs-extra";
+import { rmSync } from 'fs-extra';
describe('codegen add tests - JS', () => {
- let projectRoot: string;
- const javascriptConfig = DEFAULT_JS_CONFIG;
- const typescriptConfig: any = {
- ...DEFAULT_JS_CONFIG,
- codegenTarget: 'typescript',
- };
+ let projectRoot: string;
+ const javascriptConfig = DEFAULT_JS_CONFIG;
+ const typescriptConfig: any = {
+ ...DEFAULT_JS_CONFIG,
+ codegenTarget: 'typescript',
+ };
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('uninitializedProjectCodegenJS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('uninitializedProjectCodegenJS');
+ });
- afterEach(async () => {
- await deleteAmplifyProject(projectRoot);
- });
+ afterEach(async () => {
+ await deleteAmplifyProject(projectRoot);
+ });
- it(`graphql sdl file`, async () => {
- await testAddCodegenUninitialized({
- projectRoot,
- config: javascriptConfig,
- sdlFilename: 'schema.graphql',
- expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
- });
+ it(`graphql sdl file`, async () => {
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: javascriptConfig,
+ sdlFilename: 'schema.graphql',
+ expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
});
+ });
- it(`region is ignored if schema file is provided`, async () => {
- await testAddCodegenUninitialized({
- projectRoot,
- config: javascriptConfig,
- sdlFilename: 'schema.graphql',
- expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
- additionalParams: ['--region', 'us-fake-1'],
- });
+ it(`region is ignored if schema file is provided`, async () => {
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: javascriptConfig,
+ sdlFilename: 'schema.graphql',
+ expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
+ additionalParams: ['--region', 'us-fake-1'],
});
+ });
- it(`json sdl file`, async () => {
- await testAddCodegenUninitialized({
- projectRoot,
- config: javascriptConfig,
- sdlFilename: 'schema.json',
- expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
- });
+ it(`json sdl file`, async () => {
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: javascriptConfig,
+ sdlFilename: 'schema.json',
+ expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
});
+ });
- it(`typescript`, async () => {
- await testAddCodegenUninitialized({
- projectRoot,
- config: typescriptConfig,
- sdlFilename: 'schema.graphql',
- expectedFilenames: ['mutations.ts', 'queries.ts', 'subscriptions.ts'],
- });
+ it(`typescript`, async () => {
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: typescriptConfig,
+ sdlFilename: 'schema.graphql',
+ expectedFilenames: ['mutations.ts', 'queries.ts', 'subscriptions.ts'],
});
+ });
- it(`drop and regenerate`, async () => {
- await testAddCodegenUninitialized({
- projectRoot,
- config: typescriptConfig,
- sdlFilename: 'schema.graphql',
- expectedFilenames: ['mutations.ts', 'queries.ts', 'subscriptions.ts'],
- dropAndRunCodegen: true,
- });
+ it(`drop and regenerate`, async () => {
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: typescriptConfig,
+ sdlFilename: 'schema.graphql',
+ expectedFilenames: ['mutations.ts', 'queries.ts', 'subscriptions.ts'],
+ dropAndRunCodegen: true,
});
+ });
- it(`drop and regenerate statements`, async () => {
- await testAddCodegenUninitialized({
- projectRoot,
- config: typescriptConfig,
- sdlFilename: 'schema.graphql',
- expectedFilenames: ['mutations.ts', 'queries.ts', 'subscriptions.ts'],
- dropAndRunCodegenStatements: true,
- });
+ it(`drop and regenerate statements`, async () => {
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: typescriptConfig,
+ sdlFilename: 'schema.graphql',
+ expectedFilenames: ['mutations.ts', 'queries.ts', 'subscriptions.ts'],
+ dropAndRunCodegenStatements: true,
});
+ });
- it(`drop and regenerate types`, async () => {
- await testAddCodegenUninitialized({
- projectRoot,
- config: typescriptConfig,
- sdlFilename: 'schema.graphql',
- expectedFilenames: ['mutations.ts', 'queries.ts', 'subscriptions.ts'],
- dropAndRunCodegenStatements: true,
- dropAndRunCodegenTypes: true,
- });
+ it(`drop and regenerate types`, async () => {
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: typescriptConfig,
+ sdlFilename: 'schema.graphql',
+ expectedFilenames: ['mutations.ts', 'queries.ts', 'subscriptions.ts'],
+ dropAndRunCodegenStatements: true,
+ dropAndRunCodegenTypes: true,
});
+ });
- it(`throws a sane warning on missing graphqlconfig file`, async () => {
- // Add codegen
- await testAddCodegenUninitialized({
- projectRoot,
- config: javascriptConfig,
- sdlFilename: 'schema.graphql',
- expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
- });
+ it(`throws a sane warning on missing graphqlconfig file`, async () => {
+ // Add codegen
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: javascriptConfig,
+ sdlFilename: 'schema.graphql',
+ expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
+ });
- // Remove .graphqlconfig.yml file
- rmSync(path.join(projectRoot, '.graphqlconfig.yml'));
+ // Remove .graphqlconfig.yml file
+ rmSync(path.join(projectRoot, '.graphqlconfig.yml'));
- // Run and expect failure message
- await generateStatementsAndTypes(projectRoot, 'code generation is not configured');
- });
+ // Run and expect failure message
+ await generateStatementsAndTypes(projectRoot, 'code generation is not configured');
+ });
- it(`throws a sane warning on missing sdl schema and no api id specified`, async () => {
- await testAddCodegenUninitialized({
- projectRoot,
- config: javascriptConfig,
- expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
- initialFailureMessage: 'Provide an AppSync API ID with --apiId or manually download schema.graphql or schema.json'
- });
+ it(`throws a sane warning on missing sdl schema and no api id specified`, async () => {
+ await testAddCodegenUninitialized({
+ projectRoot,
+ config: javascriptConfig,
+ expectedFilenames: ['mutations.js', 'queries.js', 'subscriptions.js'],
+ initialFailureMessage: 'Provide an AppSync API ID with --apiId or manually download schema.graphql or schema.json',
});
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-android.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-android.test.ts
index ac8bb8015..70403e638 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-android.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-android.test.ts
@@ -5,40 +5,40 @@ import * as path from 'path';
const schemaName = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Uninitialized Project Modelgen tests - Android', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('uninitializedProjectModelgenAndroid');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('uninitializedProjectModelgenAndroid');
+ });
- afterEach(() => deleteProjectDir(projectRoot));
+ afterEach(() => deleteProjectDir(projectRoot));
- it(`should generate files at desired location and not delete src files`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_ANDROID_CONFIG,
- projectRoot,
- schemaName,
- outputDir: path.join('app', 'src', 'main', 'guava'),
- shouldSucceed: true,
- expectedFilenames: [
- 'AmplifyModelProvider.java',
- 'Attration.java',
- 'Comment.java',
- 'License.java',
- 'Person.java',
- 'Post.java',
- 'Status.java',
- 'User.java',
- ],
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_ANDROID_CONFIG,
+ projectRoot,
+ schemaName,
+ outputDir: path.join('app', 'src', 'main', 'guava'),
+ shouldSucceed: true,
+ expectedFilenames: [
+ 'AmplifyModelProvider.java',
+ 'Attration.java',
+ 'Comment.java',
+ 'License.java',
+ 'Person.java',
+ 'Post.java',
+ 'Status.java',
+ 'User.java',
+ ],
});
+ });
- it(`should not generate files at desired location and not delete src files if no output dir is specified`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_ANDROID_CONFIG,
- projectRoot,
- schemaName,
- shouldSucceed: false,
- });
+ it(`should not generate files at desired location and not delete src files if no output dir is specified`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_ANDROID_CONFIG,
+ projectRoot,
+ schemaName,
+ shouldSucceed: false,
});
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-flutter.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-flutter.test.ts
index 5c8e1beea..84f8904db 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-flutter.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-flutter.test.ts
@@ -5,40 +5,40 @@ import * as path from 'path';
const schemaName = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Uninitialized Project Modelgen tests - Flutter', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('uninitializedProjectModelgenFlutter');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('uninitializedProjectModelgenFlutter');
+ });
- afterEach(() => deleteProjectDir(projectRoot));
+ afterEach(() => deleteProjectDir(projectRoot));
- it(`should generate files at desired location and not delete src files`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_FLUTTER_CONFIG,
- projectRoot,
- schemaName,
- outputDir: path.join('lib', 'blueprints'),
- shouldSucceed: true,
- expectedFilenames: [
- 'Attration.dart',
- 'Comment.dart',
- 'License.dart',
- 'ModelProvider.dart',
- 'Person.dart',
- 'Post.dart',
- 'Status.dart',
- 'User.dart',
- ],
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_FLUTTER_CONFIG,
+ projectRoot,
+ schemaName,
+ outputDir: path.join('lib', 'blueprints'),
+ shouldSucceed: true,
+ expectedFilenames: [
+ 'Attration.dart',
+ 'Comment.dart',
+ 'License.dart',
+ 'ModelProvider.dart',
+ 'Person.dart',
+ 'Post.dart',
+ 'Status.dart',
+ 'User.dart',
+ ],
});
+ });
- it(`should not generate files at desired location and not delete src files if no output dir is specified`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_FLUTTER_CONFIG,
- projectRoot,
- schemaName,
- shouldSucceed: false,
- });
+ it(`should not generate files at desired location and not delete src files if no output dir is specified`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_FLUTTER_CONFIG,
+ projectRoot,
+ schemaName,
+ shouldSucceed: false,
});
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-ios.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-ios.test.ts
index 0e3e259fa..a580ea196 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-ios.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-ios.test.ts
@@ -5,46 +5,46 @@ import * as path from 'path';
const schemaName = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Uninitialized Project Modelgen tests - IOS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('uninitializedProjectModelgenIOS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('uninitializedProjectModelgenIOS');
+ });
- afterEach(() => deleteProjectDir(projectRoot));
+ afterEach(() => deleteProjectDir(projectRoot));
- it(`should generate files at desired location and not delete src files`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_IOS_CONFIG,
- projectRoot,
- schemaName,
- outputDir: path.join('amplification', 'manufactured', 'models'),
- shouldSucceed: true,
- expectedFilenames: [
- 'AmplifyModels.swift',
- 'Attration+Schema.swift',
- 'Attration.swift',
- 'Comment+Schema.swift',
- 'Comment.swift',
- 'License+Schema.swift',
- 'License.swift',
- 'Person+Schema.swift',
- 'Person.swift',
- 'Post+Schema.swift',
- 'Post.swift',
- 'Status.swift',
- 'User+Schema.swift',
- 'User.swift',
- ],
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_IOS_CONFIG,
+ projectRoot,
+ schemaName,
+ outputDir: path.join('amplification', 'manufactured', 'models'),
+ shouldSucceed: true,
+ expectedFilenames: [
+ 'AmplifyModels.swift',
+ 'Attration+Schema.swift',
+ 'Attration.swift',
+ 'Comment+Schema.swift',
+ 'Comment.swift',
+ 'License+Schema.swift',
+ 'License.swift',
+ 'Person+Schema.swift',
+ 'Person.swift',
+ 'Post+Schema.swift',
+ 'Post.swift',
+ 'Status.swift',
+ 'User+Schema.swift',
+ 'User.swift',
+ ],
});
+ });
- it(`should not generate files at desired location and not delete src files if no output dir is specified`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_IOS_CONFIG,
- projectRoot,
- schemaName,
- shouldSucceed: false,
- });
+ it(`should not generate files at desired location and not delete src files if no output dir is specified`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_IOS_CONFIG,
+ projectRoot,
+ schemaName,
+ shouldSucceed: false,
});
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-js.test.ts b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-js.test.ts
index adedce7f2..bcdb07409 100644
--- a/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-js.test.ts
+++ b/packages/amplify-codegen-e2e-tests/src/__tests__/uninitialized-project-modelgen-js.test.ts
@@ -5,50 +5,42 @@ import * as path from 'path';
const schemaName = 'modelgen/model_gen_schema_with_aws_scalars.graphql';
describe('Uninitialized Project Modelgen tests - JS', () => {
- let projectRoot: string;
+ let projectRoot: string;
- beforeEach(async () => {
- projectRoot = await createNewProjectDir('uninitializedProjectModelgenJS');
- });
+ beforeEach(async () => {
+ projectRoot = await createNewProjectDir('uninitializedProjectModelgenJS');
+ });
- afterEach(() => deleteProjectDir(projectRoot));
+ afterEach(() => deleteProjectDir(projectRoot));
- it(`should generate files at desired location and not delete src files`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_JS_CONFIG,
- projectRoot,
- schemaName,
- outputDir: path.join('src', 'backmodels'),
- shouldSucceed: true,
- expectedFilenames: [
- 'index.d.ts',
- 'index.js',
- 'schema.d.ts',
- 'schema.js',
- ],
- });
+ it(`should generate files at desired location and not delete src files`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_JS_CONFIG,
+ projectRoot,
+ schemaName,
+ outputDir: path.join('src', 'backmodels'),
+ shouldSucceed: true,
+ expectedFilenames: ['index.d.ts', 'index.js', 'schema.d.ts', 'schema.js'],
});
+ });
- it(`should generate files at desired location and not delete src files for typescript variant`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_TS_CONFIG,
- projectRoot,
- schemaName,
- outputDir: path.join('src', 'backmodels'),
- shouldSucceed: true,
- expectedFilenames: [
- 'index.ts',
- 'schema.ts',
- ],
- });
+ it(`should generate files at desired location and not delete src files for typescript variant`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_TS_CONFIG,
+ projectRoot,
+ schemaName,
+ outputDir: path.join('src', 'backmodels'),
+ shouldSucceed: true,
+ expectedFilenames: ['index.ts', 'schema.ts'],
});
+ });
- it(`should not generate files at desired location and not delete src files if no output dir is specified`, async () => {
- await testUninitializedCodegenModels({
- config: DEFAULT_JS_CONFIG,
- projectRoot,
- schemaName,
- shouldSucceed: false,
- });
+ it(`should not generate files at desired location and not delete src files if no output dir is specified`, async () => {
+ await testUninitializedCodegenModels({
+ config: DEFAULT_JS_CONFIG,
+ projectRoot,
+ schemaName,
+ shouldSucceed: false,
});
+ });
});
diff --git a/packages/amplify-codegen-e2e-tests/src/aws-matchers/iamMatcher.ts b/packages/amplify-codegen-e2e-tests/src/aws-matchers/iamMatcher.ts
index f4929ee1a..42f015119 100644
--- a/packages/amplify-codegen-e2e-tests/src/aws-matchers/iamMatcher.ts
+++ b/packages/amplify-codegen-e2e-tests/src/aws-matchers/iamMatcher.ts
@@ -41,7 +41,7 @@ export const toHaveValidPolicyConditionMatchingIdpId = async (roleName: string,
const { Role: role } = await iam.getRole({ RoleName: roleName }).promise();
const assumeRolePolicyDocument = JSON.parse(decodeURIComponent(role.AssumeRolePolicyDocument));
- pass = assumeRolePolicyDocument.Statement.some(statement => {
+ pass = assumeRolePolicyDocument.Statement.some((statement) => {
if (statement.Condition) {
return (
statement.Condition.StringEquals &&
@@ -57,7 +57,6 @@ export const toHaveValidPolicyConditionMatchingIdpId = async (roleName: string,
});
message = pass ? 'Found Matching Condition' : 'Matching Condition does not exist';
-
} catch (e) {
pass = false;
message = 'IAM GetRole threw Error: ' + e.message;
diff --git a/packages/amplify-codegen-e2e-tests/src/cleanup-e2e-resources.ts b/packages/amplify-codegen-e2e-tests/src/cleanup-e2e-resources.ts
index a09976c5f..a2c8a1ed2 100644
--- a/packages/amplify-codegen-e2e-tests/src/cleanup-e2e-resources.ts
+++ b/packages/amplify-codegen-e2e-tests/src/cleanup-e2e-resources.ts
@@ -88,7 +88,7 @@ const BUCKET_TEST_REGEX = /test/;
const IAM_TEST_REGEX = /!RotateE2eAwsToken-e2eTestContextRole|-integtest$|^amplify-|^eu-|^us-|^ap-/;
const STALE_DURATION_MS = 2 * 60 * 60 * 1000; // 2 hours in milliseconds
-const isCI = (): boolean => process.env.CI && process.env.CODEBUILD ? true : false;
+const isCI = (): boolean => (process.env.CI && process.env.CODEBUILD ? true : false);
/*
* Exit on expired token as all future requests will fail.
*/
@@ -102,13 +102,13 @@ const handleExpiredTokenException = (): void => {
*/
const testBucketStalenessFilter = (resource: aws.S3.Bucket): boolean => {
const isTestResource = resource.Name.match(BUCKET_TEST_REGEX);
- const isStaleResource = (Date.now() - resource.CreationDate.getMilliseconds()) > STALE_DURATION_MS;
+ const isStaleResource = Date.now() - resource.CreationDate.getMilliseconds() > STALE_DURATION_MS;
return isTestResource && isStaleResource;
};
const testRoleStalenessFilter = (resource: aws.IAM.Role): boolean => {
const isTestResource = resource.RoleName.match(IAM_TEST_REGEX);
- const isStaleResource = (Date.now() - resource.CreateDate.getMilliseconds()) > STALE_DURATION_MS;
+ const isStaleResource = Date.now() - resource.CreateDate.getMilliseconds() > STALE_DURATION_MS;
return isTestResource && isStaleResource;
};
@@ -138,13 +138,13 @@ const getOrphanTestIamRoles = async (account: AWSAccountInfo): Promise ({ name: it.RoleName }));
+ return staleRoles.map((it) => ({ name: it.RoleName }));
};
/**
* Get the relevant AWS config object for a given account and region.
*/
- const getAWSConfig = ({ accessKeyId, secretAccessKey, sessionToken }: AWSAccountInfo, region?: string): unknown => ({
+const getAWSConfig = ({ accessKeyId, secretAccessKey, sessionToken }: AWSAccountInfo, region?: string): unknown => ({
credentials: {
accessKeyId,
secretAccessKey,
@@ -194,7 +194,7 @@ const getAmplifyApps = async (account: AWSAccountInfo, region: string): Promise<
* @returns build number or undefined
*/
const getJobId = (tags: aws.CloudFormation.Tags = []): string | undefined => {
- const jobId = tags.find(tag => tag.Key === 'codebuild:build_id')?.Value;
+ const jobId = tags.find((tag) => tag.Key === 'codebuild:build_id')?.Value;
return jobId;
};
@@ -217,8 +217,8 @@ const getStackDetails = async (stackName: string, account: AWSAccountInfo, regio
if (stackStatus === 'DELETE_FAILED') {
// TODO: We need to investigate if we should go ahead and remove the resources to prevent account getting cluttered
const resources = await cfnClient.listStackResources({ StackName: stackName }).promise();
- resourcesFailedToDelete = resources.StackResourceSummaries.filter(r => r.ResourceStatus === 'DELETE_FAILED').map(
- r => r.LogicalResourceId,
+ resourcesFailedToDelete = resources.StackResourceSummaries.filter((r) => r.ResourceStatus === 'DELETE_FAILED').map(
+ (r) => r.LogicalResourceId,
);
}
const jobId = getJobId(tags);
@@ -228,7 +228,7 @@ const getStackDetails = async (stackName: string, account: AWSAccountInfo, regio
resourcesFailedToDelete,
region,
tags: tags.reduce((acc, tag) => ({ ...acc, [tag.Key]: tag.Value }), {}),
- jobId
+ jobId,
};
};
@@ -251,7 +251,7 @@ const getStacks = async (account: AWSAccountInfo, region: string): Promise !stack.RootId);
+ const rootStacks = stacks.StackSummaries.filter((stack) => !stack.RootId);
const results: StackInfo[] = [];
for (const stack of rootStacks) {
try {
@@ -281,7 +281,7 @@ const getJobCodeBuildDetails = async (jobIds: string[]): Promise =>
result.push({
name: bucket.Name,
region,
- jobId
+ jobId,
});
}
} catch (e) {
@@ -340,20 +340,16 @@ const getS3Buckets = async (account: AWSAccountInfo): Promise =>
/**
* extract and moves CI job details
*/
-const extractCCIJobInfo = (
- record: S3BucketInfo | StackInfo | AmplifyAppInfo,
- buildInfos: Record
- ): CBJobInfo => {
+const extractCCIJobInfo = (record: S3BucketInfo | StackInfo | AmplifyAppInfo, buildInfos: Record): CBJobInfo => {
const buildId = _.get(record, ['0', 'jobId']);
return {
- buildBatchArn: _.get(buildInfos, [ buildId, '0', 'buildBatchArn' ]),
- projectName: _.get(buildInfos, [ buildId, '0', 'projectName' ]),
- buildComplete: _.get(buildInfos, [ buildId, '0', 'buildComplete' ]),
- cbJobDetails: _.get(buildInfos, [ buildId, '0' ]),
- buildStatus: _.get(buildInfos, [ buildId, '0', 'buildStatus' ])
+ buildBatchArn: _.get(buildInfos, [buildId, '0', 'buildBatchArn']),
+ projectName: _.get(buildInfos, [buildId, '0', 'projectName']),
+ buildComplete: _.get(buildInfos, [buildId, '0', 'buildComplete']),
+ cbJobDetails: _.get(buildInfos, [buildId, '0']),
+ buildStatus: _.get(buildInfos, [buildId, '0', 'buildStatus']),
};
-}
-
+};
/**
* Merges stale resources and returns a list grouped by the CodeBuild jobId. Amplify Apps that don't have
@@ -378,15 +374,18 @@ const mergeResourcesByCCIJob = async (
return ORPHAN;
}
- const buildIds = _.groupBy(appInfo.backends, backendInfo => _.get(backendInfo, ['jobId'], UNKNOWN));
+ const buildIds = _.groupBy(appInfo.backends, (backendInfo) => _.get(backendInfo, ['jobId'], UNKNOWN));
if (Object.keys(buildIds).length === 1) {
return Object.keys(buildIds)[0];
}
return MULTI_JOB_APP;
});
- const codeBuildJobIds: string[] = _.uniq([...Object.keys(stacksByJobId), ...Object.keys(bucketByJobId), ...Object.keys(amplifyAppByJobId)])
- .filter((jobId: string) => jobId !== UNKNOWN && jobId !== ORPHAN && jobId !== MULTI_JOB_APP)
+ const codeBuildJobIds: string[] = _.uniq([
+ ...Object.keys(stacksByJobId),
+ ...Object.keys(bucketByJobId),
+ ...Object.keys(amplifyAppByJobId),
+ ]).filter((jobId: string) => jobId !== UNKNOWN && jobId !== ORPHAN && jobId !== MULTI_JOB_APP);
const buildInfos = await getJobCodeBuildDetails(codeBuildJobIds);
const buildInfosByJobId = _.groupBy(buildInfos, (build: CodeBuild.Build) => _.get(build, ['id']));
_.mergeWith(
@@ -443,7 +442,7 @@ const mergeResourcesByCCIJob = async (
};
const deleteAmplifyApps = async (account: AWSAccountInfo, accountIndex: number, apps: AmplifyAppInfo[]): Promise => {
- await Promise.all(apps.map(app => deleteAmplifyApp(account, accountIndex, app)));
+ await Promise.all(apps.map((app) => deleteAmplifyApp(account, accountIndex, app)));
};
const deleteAmplifyApp = async (account: AWSAccountInfo, accountIndex: number, app: AmplifyAppInfo): Promise => {
@@ -466,7 +465,7 @@ const deleteIamRoles = async (account: AWSAccountInfo, accountIndex: number, rol
const batchSize = 20;
for (var i = 0; i < roles.length; i += batchSize) {
const rolesToDelete = roles.slice(i, i + batchSize);
- await Promise.all(rolesToDelete.map(role => deleteIamRole(account, accountIndex, role)));
+ await Promise.all(rolesToDelete.map((role) => deleteIamRole(account, accountIndex, role)));
await sleep(5000);
}
};
@@ -487,14 +486,10 @@ const deleteIamRole = async (account: AWSAccountInfo, accountIndex: number, role
}
};
-const deleteAttachedRolePolicies = async (
- account: AWSAccountInfo,
- accountIndex: number,
- roleName: string,
-): Promise => {
+const deleteAttachedRolePolicies = async (account: AWSAccountInfo, accountIndex: number, roleName: string): Promise => {
const iamClient = new aws.IAM(getAWSConfig(account));
const rolePolicies = await iamClient.listAttachedRolePolicies({ RoleName: roleName }).promise();
- await Promise.all(rolePolicies.AttachedPolicies.map(policy => detachIamAttachedRolePolicy(account, accountIndex, roleName, policy)));
+ await Promise.all(rolePolicies.AttachedPolicies.map((policy) => detachIamAttachedRolePolicy(account, accountIndex, roleName, policy)));
};
const detachIamAttachedRolePolicy = async (
@@ -515,22 +510,13 @@ const detachIamAttachedRolePolicy = async (
}
};
-const deleteRolePolicies = async (
- account: AWSAccountInfo,
- accountIndex: number,
- roleName: string,
-): Promise => {
+const deleteRolePolicies = async (account: AWSAccountInfo, accountIndex: number, roleName: string): Promise => {
const iamClient = new aws.IAM(getAWSConfig(account));
const rolePolicies = await iamClient.listRolePolicies({ RoleName: roleName }).promise();
- await Promise.all(rolePolicies.PolicyNames.map(policy => deleteIamRolePolicy(account, accountIndex, roleName, policy)));
+ await Promise.all(rolePolicies.PolicyNames.map((policy) => deleteIamRolePolicy(account, accountIndex, roleName, policy)));
};
-const deleteIamRolePolicy = async (
- account: AWSAccountInfo,
- accountIndex: number,
- roleName: string,
- policyName: string,
-): Promise => {
+const deleteIamRolePolicy = async (account: AWSAccountInfo, accountIndex: number, roleName: string, policyName: string): Promise => {
try {
console.log(`${generateAccountInfo(account, accountIndex)} Deleting Iam Role Policy ${policyName}`);
const iamClient = new aws.IAM(getAWSConfig(account));
@@ -544,7 +530,7 @@ const deleteIamRolePolicy = async (
};
const deleteBuckets = async (account: AWSAccountInfo, accountIndex: number, buckets: S3BucketInfo[]): Promise => {
- await Promise.all(buckets.map(bucket => deleteBucket(account, accountIndex, bucket)));
+ await Promise.all(buckets.map((bucket) => deleteBucket(account, accountIndex, bucket)));
};
const deleteBucket = async (account: AWSAccountInfo, accountIndex: number, bucket: S3BucketInfo): Promise => {
@@ -566,7 +552,7 @@ const deleteBucket = async (account: AWSAccountInfo, accountIndex: number, bucke
};
const deleteCfnStacks = async (account: AWSAccountInfo, accountIndex: number, stacks: StackInfo[]): Promise => {
- await Promise.all(stacks.map(stack => deleteCfnStack(account, accountIndex, stack)));
+ await Promise.all(stacks.map((stack) => deleteCfnStack(account, accountIndex, stack)));
};
const deleteCfnStack = async (account: AWSAccountInfo, accountIndex: number, stack: StackInfo): Promise => {
@@ -648,39 +634,39 @@ const getFilterPredicate = (args: any): JobFilterPredicate => {
const getAccountsToCleanup = async (): Promise => {
// This script runs using the codebuild project role to begin with
const stsClient = new aws.STS({
- apiVersion: '2011-06-15'
+ apiVersion: '2011-06-15',
});
const assumeRoleResForE2EParent = await stsClient
- .assumeRole({
- RoleArn: process.env.TEST_ACCOUNT_ROLE,
- RoleSessionName: `testSession${Math.floor(Math.random() * 100000)}`,
- // One hour
- DurationSeconds: 1 * 60 * 60,
- })
- .promise();
+ .assumeRole({
+ RoleArn: process.env.TEST_ACCOUNT_ROLE,
+ RoleSessionName: `testSession${Math.floor(Math.random() * 100000)}`,
+ // One hour
+ DurationSeconds: 1 * 60 * 60,
+ })
+ .promise();
const e2eParentAccountCred = {
accessKeyId: assumeRoleResForE2EParent.Credentials.AccessKeyId,
secretAccessKey: assumeRoleResForE2EParent.Credentials.SecretAccessKey,
- sessionToken: assumeRoleResForE2EParent.Credentials.SessionToken
- }
+ sessionToken: assumeRoleResForE2EParent.Credentials.SessionToken,
+ };
const stsClientForE2E = new aws.STS({
apiVersion: '2011-06-15',
- credentials: e2eParentAccountCred
+ credentials: e2eParentAccountCred,
});
- const parentAccountIdentity = await stsClientForE2E.getCallerIdentity().promise()
+ const parentAccountIdentity = await stsClientForE2E.getCallerIdentity().promise();
const orgApi = new aws.Organizations({
apiVersion: '2016-11-28',
// the region where the organization exists
region: 'us-east-1',
- credentials: e2eParentAccountCred
+ credentials: e2eParentAccountCred,
});
try {
const orgAccounts = await orgApi.listAccounts().promise();
- const accountCredentialPromises = orgAccounts.Accounts.map(async account => {
+ const accountCredentialPromises = orgAccounts.Accounts.map(async (account) => {
if (account.Id === parentAccountIdentity.Account) {
return {
accountId: account.Id,
- ...e2eParentAccountCred
+ ...e2eParentAccountCred,
};
}
const randomNumber = Math.floor(Math.random() * 100000);
@@ -702,19 +688,21 @@ const getAccountsToCleanup = async (): Promise => {
return await Promise.all(accountCredentialPromises);
} catch (e) {
console.error(e);
- console.log('Error assuming child account role. This could be because the script is already running from within a child account. Running on current AWS account only.');
+ console.log(
+ 'Error assuming child account role. This could be because the script is already running from within a child account. Running on current AWS account only.',
+ );
return [
{
accountId: parentAccountIdentity.Account,
- ...e2eParentAccountCred
+ ...e2eParentAccountCred,
},
];
}
};
const cleanupAccount = async (account: AWSAccountInfo, accountIndex: number, filterPredicate: JobFilterPredicate): Promise => {
- const appPromises = AWS_REGIONS_TO_RUN_TESTS.map(region => getAmplifyApps(account, region));
- const stackPromises = AWS_REGIONS_TO_RUN_TESTS.map(region => getStacks(account, region));
+ const appPromises = AWS_REGIONS_TO_RUN_TESTS.map((region) => getAmplifyApps(account, region));
+ const stackPromises = AWS_REGIONS_TO_RUN_TESTS.map((region) => getStacks(account, region));
const bucketPromise = getS3Buckets(account);
const orphanBucketPromise = getOrphanS3TestBuckets(account);
const orphanIamRolesPromise = getOrphanTestIamRoles(account);
@@ -734,7 +722,7 @@ const cleanupAccount = async (account: AWSAccountInfo, accountIndex: number, fil
};
const generateAccountInfo = (account: AWSAccountInfo, accountIndex: number): string => {
- return (`[ACCOUNT ${accountIndex}][${account.accountId}]`);
+ return `[ACCOUNT ${accountIndex}][${account.accountId}]`;
};
/**
@@ -747,14 +735,14 @@ const generateAccountInfo = (account: AWSAccountInfo, accountIndex: number): str
const cleanup = async (): Promise => {
const args = yargs
.command('*', 'clean up all the stale resources')
- .command('buildBatchArn ', 'clean all the resources created by batch build', _yargs => {
+ .command('buildBatchArn ', 'clean all the resources created by batch build', (_yargs) => {
_yargs.positional('buildBatchArn', {
describe: 'ARN of batch build',
type: 'string',
demandOption: '',
});
})
- .command('job ', 'clean all the resource created by a job', _yargs => {
+ .command('job ', 'clean all the resource created by a job', (_yargs) => {
_yargs.positional('jobId', {
describe: 'job id of the job',
type: 'string',
diff --git a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/add-codegen.ts b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/add-codegen.ts
index 7324cfcb3..17b4d49d3 100644
--- a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/add-codegen.ts
+++ b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/add-codegen.ts
@@ -1,24 +1,24 @@
import {
- initProjectWithProfile,
- addApiWithoutSchema,
- updateApiSchema,
- addCodegen,
- AmplifyFrontendConfig,
- createRandomName,
- addCodegenNonAmplifyJS,
- addCodegenNonAmplifyTS,
- AmplifyFrontend,
- generateStatementsAndTypes,
- generateStatements,
- generateTypes,
- amplifyConfigureProjectInfo,
- deleteProjectDir,
- DEFAULT_JS_CONFIG,
-} from "@aws-amplify/amplify-codegen-e2e-core";
-import { existsSync, readFileSync, writeFileSync, readdirSync, rmSync, lstatSync } from "fs";
+ initProjectWithProfile,
+ addApiWithoutSchema,
+ updateApiSchema,
+ addCodegen,
+ AmplifyFrontendConfig,
+ createRandomName,
+ addCodegenNonAmplifyJS,
+ addCodegenNonAmplifyTS,
+ AmplifyFrontend,
+ generateStatementsAndTypes,
+ generateStatements,
+ generateTypes,
+ amplifyConfigureProjectInfo,
+ deleteProjectDir,
+ DEFAULT_JS_CONFIG,
+} from '@aws-amplify/amplify-codegen-e2e-core';
+import { existsSync, readFileSync, writeFileSync, readdirSync, rmSync, lstatSync } from 'fs';
import path from 'path';
import { isNotEmptyDir } from '../utils';
-import { getGraphQLConfigFilePath, testSetupBeforeAddCodegen, testValidGraphQLConfig } from "./test-setup";
+import { getGraphQLConfigFilePath, testSetupBeforeAddCodegen, testValidGraphQLConfig } from './test-setup';
export type CodegenMatrixTestProps = AmplifyFrontendConfig & {
params?: string[];
@@ -31,7 +31,7 @@ export type CodegenMatrixTestProps = AmplifyFrontendConfig & {
maxDepth?: number;
isTypeGenerated?: boolean;
typeFileName?: string;
-}
+};
const defaultConfig: CodegenMatrixTestProps = {
...DEFAULT_JS_CONFIG,
@@ -43,7 +43,7 @@ const defaultConfig: CodegenMatrixTestProps = {
maxDepth: 2, // default value
isTypeGenerated: true,
typeFileName: '\r', // default value
-}
+};
/**
* Extract type file path given the test props. When the carriage return is detected, the default path will be returned
@@ -55,7 +55,7 @@ const getTypeFilePath = (props: CodegenMatrixTestProps, projectRoot: string): st
if (props.typeFileName) {
if (props.typeFileName === '\r') {
if (props.frontendType === AmplifyFrontend.ios) {
- return path.join(projectRoot, 'API.swift')
+ return path.join(projectRoot, 'API.swift');
} else if (props.frontendType === AmplifyFrontend.javascript) {
switch (props.codegenTarget) {
case 'flow':
@@ -72,7 +72,7 @@ const getTypeFilePath = (props: CodegenMatrixTestProps, projectRoot: string): st
return path.join(projectRoot, props.typeFileName);
}
return undefined;
-}
+};
/**
* Check if the type file(s) is generated at the given file path(single file or directory)
@@ -92,7 +92,7 @@ const isTypeFileGeneratedAtPath = (filePath: string | undefined): boolean => {
return false;
}
return false;
-}
+};
/**
* Util function for testing codegen matrix
@@ -100,7 +100,7 @@ const isTypeFileGeneratedAtPath = (filePath: string | undefined): boolean => {
* @param projectRoot project root
*/
export async function testAddCodegenMatrix(props: CodegenMatrixTestProps, projectRoot: string): Promise {
- const config: CodegenMatrixTestProps = { ...defaultConfig, ...props }
+ const config: CodegenMatrixTestProps = { ...defaultConfig, ...props };
if (config.graphqlCodegenDir) {
deleteProjectDir(path.join(projectRoot, config.graphqlCodegenDir));
}
@@ -124,42 +124,42 @@ export async function testAddCodegenMatrix(props: CodegenMatrixTestProps, projec
// pre-existing file should still exist
expect(existsSync(userSourceCodePath)).toBe(true);
// Check if type files are generated
- expect(isTypeFileGeneratedAtPath(typeFilePath)).toBe(config.isTypeGenerated)
+ expect(isTypeFileGeneratedAtPath(typeFilePath)).toBe(config.isTypeGenerated);
}
export async function testAddCodegen(config: AmplifyFrontendConfig, projectRoot: string, schema: string, additionalParams?: Array) {
- // init project and add API category
- await initProjectWithProfile(projectRoot, { ...config });
- const projectName = createRandomName();
- await addApiWithoutSchema(projectRoot, { apiName: projectName });
- await updateApiSchema(projectRoot, projectName, schema);
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { ...config });
+ const projectName = createRandomName();
+ await addApiWithoutSchema(projectRoot, { apiName: projectName });
+ await updateApiSchema(projectRoot, projectName, schema);
- const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
+ const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
- // add codegen succeeds
- await expect(addCodegen(projectRoot, { ...config, params: additionalParams ?? [] })).resolves.not.toThrow();
+ // add codegen succeeds
+ await expect(addCodegen(projectRoot, { ...config, params: additionalParams ?? [] })).resolves.not.toThrow();
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
- // GraphQL statements are generated
- expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
- testValidGraphQLConfig(projectRoot, config);
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
+ // GraphQL statements are generated
+ expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
+ testValidGraphQLConfig(projectRoot, config);
}
export type TestAddCodegenUninitializedProps = {
- config: AmplifyFrontendConfig;
- projectRoot: string;
- sdlFilename?: string;
- expectedFilenames: Array;
- dropAndRunCodegen?: boolean;
- dropAndRunCodegenStatements?: boolean;
- dropAndRunCodegenTypes?: boolean;
- initialFailureMessage?: string;
- additionalParams?: Array;
+ config: AmplifyFrontendConfig;
+ projectRoot: string;
+ sdlFilename?: string;
+ expectedFilenames: Array;
+ dropAndRunCodegen?: boolean;
+ dropAndRunCodegenStatements?: boolean;
+ dropAndRunCodegenTypes?: boolean;
+ initialFailureMessage?: string;
+ additionalParams?: Array;
};
const assertTypeFileExists = (projectRoot: string): void => {
- expect(existsSync(path.join(projectRoot, 'src', 'API.ts'))).toBe(true)
+ expect(existsSync(path.join(projectRoot, 'src', 'API.ts'))).toBe(true);
};
/**
@@ -168,98 +168,97 @@ const assertTypeFileExists = (projectRoot: string): void => {
* @param receivedValues the received values to check
*/
const ensureAllExpectedValuesAreReceived = (expectedValues: Array, receivedValues: Array): void => {
- const receivedValueSet = new Set(receivedValues);
- console.log(`Comparing received values: ${JSON.stringify(receivedValues)} to expected values: ${JSON.stringify(expectedValues)}`);
- expectedValues.forEach((expectedFilename) => expect(receivedValueSet.has(expectedFilename)).toBe(true));
+ const receivedValueSet = new Set(receivedValues);
+ console.log(`Comparing received values: ${JSON.stringify(receivedValues)} to expected values: ${JSON.stringify(expectedValues)}`);
+ expectedValues.forEach((expectedFilename) => expect(receivedValueSet.has(expectedFilename)).toBe(true));
};
export async function testAddCodegenUninitialized({
- config,
- projectRoot,
- sdlFilename,
- expectedFilenames,
- dropAndRunCodegen,
- dropAndRunCodegenStatements,
- dropAndRunCodegenTypes,
- initialFailureMessage,
- additionalParams,
+ config,
+ projectRoot,
+ sdlFilename,
+ expectedFilenames,
+ dropAndRunCodegen,
+ dropAndRunCodegenStatements,
+ dropAndRunCodegenTypes,
+ initialFailureMessage,
+ additionalParams,
}: TestAddCodegenUninitializedProps) {
- // Setup the non-amplify project with schema and pre-existing files
- const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
+ // Setup the non-amplify project with schema and pre-existing files
+ const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
- // Write SDL Schema
- if (sdlFilename) {
- const sdlSchema = readFileSync(path.join(__dirname, '..', '..', 'schemas', 'sdl', sdlFilename), 'utf-8');
- writeFileSync(path.join(projectRoot, sdlFilename), sdlSchema);
- }
+ // Write SDL Schema
+ if (sdlFilename) {
+ const sdlSchema = readFileSync(path.join(__dirname, '..', '..', 'schemas', 'sdl', sdlFilename), 'utf-8');
+ writeFileSync(path.join(projectRoot, sdlFilename), sdlSchema);
+ }
- let isTypeGenIncluded = false;
- // add codegen without init
- switch (config.frontendType) {
- case AmplifyFrontend.javascript:
- switch (config.codegenTarget) {
- case 'javascript':
- await addCodegenNonAmplifyJS(projectRoot, additionalParams ?? [], initialFailureMessage);
- break;
- case 'typescript':
- isTypeGenIncluded = true;
- await addCodegenNonAmplifyTS(projectRoot, additionalParams ?? [], initialFailureMessage);
- break;
- default:
- throw new Error(`Received unexpected codegen target ${config.codegenTarget}`);
- }
- break;
- default:
- throw new Error(`Received unexpected frontendType ${config.frontendType}`);
- }
+ let isTypeGenIncluded = false;
+ // add codegen without init
+ switch (config.frontendType) {
+ case AmplifyFrontend.javascript:
+ switch (config.codegenTarget) {
+ case 'javascript':
+ await addCodegenNonAmplifyJS(projectRoot, additionalParams ?? [], initialFailureMessage);
+ break;
+ case 'typescript':
+ isTypeGenIncluded = true;
+ await addCodegenNonAmplifyTS(projectRoot, additionalParams ?? [], initialFailureMessage);
+ break;
+ default:
+ throw new Error(`Received unexpected codegen target ${config.codegenTarget}`);
+ }
+ break;
+ default:
+ throw new Error(`Received unexpected frontendType ${config.frontendType}`);
+ }
+ // return if we expected the add command to fail
+ if (initialFailureMessage) {
+ return;
+ }
- // return if we expected the add command to fail
- if (initialFailureMessage) {
- return;
- }
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
+ // GraphQL statements are generated
+ ensureAllExpectedValuesAreReceived(expectedFilenames, readdirSync(path.join(projectRoot, config.graphqlCodegenDir)));
+ // graphql configuration should be added
+ expect(existsSync(getGraphQLConfigFilePath(projectRoot))).toBe(true);
+ if (isTypeGenIncluded) {
+ assertTypeFileExists(projectRoot);
+ }
+ if (dropAndRunCodegen || dropAndRunCodegenStatements || dropAndRunCodegenTypes) {
+ rmSync(path.join(projectRoot, config.graphqlCodegenDir), { recursive: true });
// pre-existing file should still exist
expect(existsSync(userSourceCodePath)).toBe(true);
- // GraphQL statements are generated
- ensureAllExpectedValuesAreReceived(expectedFilenames, readdirSync(path.join(projectRoot, config.graphqlCodegenDir)))
- // graphql configuration should be added
- expect(existsSync(getGraphQLConfigFilePath(projectRoot))).toBe(true);
- if (isTypeGenIncluded) {
- assertTypeFileExists(projectRoot)
- }
-
- if (dropAndRunCodegen || dropAndRunCodegenStatements || dropAndRunCodegenTypes) {
- rmSync(path.join(projectRoot, config.graphqlCodegenDir), { recursive: true });
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
- // Graphql statements are deleted
- expect(existsSync(path.join(projectRoot, config.graphqlCodegenDir))).toBe(false);
- }
+ // Graphql statements are deleted
+ expect(existsSync(path.join(projectRoot, config.graphqlCodegenDir))).toBe(false);
+ }
- if (dropAndRunCodegen) {
- await generateStatementsAndTypes(projectRoot);
+ if (dropAndRunCodegen) {
+ await generateStatementsAndTypes(projectRoot);
- // GraphQL statements are regenerated
- ensureAllExpectedValuesAreReceived(expectedFilenames, readdirSync(path.join(projectRoot, config.graphqlCodegenDir)))
+ // GraphQL statements are regenerated
+ ensureAllExpectedValuesAreReceived(expectedFilenames, readdirSync(path.join(projectRoot, config.graphqlCodegenDir)));
- if (isTypeGenIncluded) {
- assertTypeFileExists(projectRoot)
- }
+ if (isTypeGenIncluded) {
+ assertTypeFileExists(projectRoot);
}
+ }
- if (dropAndRunCodegenStatements) {
- await generateStatements(projectRoot);
+ if (dropAndRunCodegenStatements) {
+ await generateStatements(projectRoot);
- // GraphQL statements are regenerated
- ensureAllExpectedValuesAreReceived(expectedFilenames, readdirSync(path.join(projectRoot, config.graphqlCodegenDir)))
- }
+ // GraphQL statements are regenerated
+ ensureAllExpectedValuesAreReceived(expectedFilenames, readdirSync(path.join(projectRoot, config.graphqlCodegenDir)));
+ }
- if (dropAndRunCodegenTypes) {
- await generateTypes(projectRoot);
+ if (dropAndRunCodegenTypes) {
+ await generateTypes(projectRoot);
- if (isTypeGenIncluded) {
- assertTypeFileExists(projectRoot)
- }
+ if (isTypeGenIncluded) {
+ assertTypeFileExists(projectRoot);
}
+ }
}
diff --git a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/configure-codegen.ts b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/configure-codegen.ts
index 71286f7b3..126e4657c 100644
--- a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/configure-codegen.ts
+++ b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/configure-codegen.ts
@@ -1,43 +1,43 @@
import {
- initProjectWithProfile,
- addApiWithoutSchema,
- addCodegen,
- updateApiSchema,
- configureCodegen,
- AmplifyFrontendConfig,
- createRandomName
-} from "@aws-amplify/amplify-codegen-e2e-core";
-import { existsSync, readFileSync } from "fs";
+ initProjectWithProfile,
+ addApiWithoutSchema,
+ addCodegen,
+ updateApiSchema,
+ configureCodegen,
+ AmplifyFrontendConfig,
+ createRandomName,
+} from '@aws-amplify/amplify-codegen-e2e-core';
+import { existsSync, readFileSync } from 'fs';
import path from 'path';
import { isNotEmptyDir } from '../utils';
-import { testSetupBeforeAddCodegen, testValidGraphQLConfig, getGraphQLConfigFilePath } from "./test-setup";
+import { testSetupBeforeAddCodegen, testValidGraphQLConfig, getGraphQLConfigFilePath } from './test-setup';
export async function testConfigureCodegen(config: AmplifyFrontendConfig, projectRoot: string, schema: string) {
- // init project and add API category
- await initProjectWithProfile(projectRoot, { ...config });
- const projectName = createRandomName();
- await addApiWithoutSchema(projectRoot, { apiName: projectName });
- await updateApiSchema(projectRoot, projectName, schema);
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { ...config });
+ const projectName = createRandomName();
+ await addApiWithoutSchema(projectRoot, { apiName: projectName });
+ await updateApiSchema(projectRoot, projectName, schema);
- const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
+ const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
- // add codegen succeeds
- await expect(addCodegen(projectRoot, { ...config })).resolves.not.toThrow();
+ // add codegen succeeds
+ await expect(addCodegen(projectRoot, { ...config })).resolves.not.toThrow();
- const addedCodegenConfiguration = readFileSync(getGraphQLConfigFilePath(projectRoot)).toString();
+ const addedCodegenConfiguration = readFileSync(getGraphQLConfigFilePath(projectRoot)).toString();
- // update codegen configuration
- const settings = { isCodegenConfigured: true, maxStatementDepth: 4, ...config };
- await expect(configureCodegen(projectRoot, settings)).resolves.not.toThrow();
+ // update codegen configuration
+ const settings = { isCodegenConfigured: true, maxStatementDepth: 4, ...config };
+ await expect(configureCodegen(projectRoot, settings)).resolves.not.toThrow();
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
- // previously generated files should still exist
- expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
+ // previously generated files should still exist
+ expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
- // graphql configuration should be updated to with MaxStatementDepth=4
- testValidGraphQLConfig(projectRoot, config, 4, true);
- const updatedCodegenConfiguration = readFileSync(getGraphQLConfigFilePath(projectRoot)).toString();
- // the codegen configuration is updated
- expect(addedCodegenConfiguration).not.toMatch(updatedCodegenConfiguration);
-}
\ No newline at end of file
+ // graphql configuration should be updated to with MaxStatementDepth=4
+ testValidGraphQLConfig(projectRoot, config, 4, true);
+ const updatedCodegenConfiguration = readFileSync(getGraphQLConfigFilePath(projectRoot)).toString();
+ // the codegen configuration is updated
+ expect(addedCodegenConfiguration).not.toMatch(updatedCodegenConfiguration);
+}
diff --git a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/datastore-modelgen.ts b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/datastore-modelgen.ts
index a2b4ba924..5d3cc2634 100644
--- a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/datastore-modelgen.ts
+++ b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/datastore-modelgen.ts
@@ -1,58 +1,56 @@
import {
- initProjectWithProfile,
- addApiWithBlankSchemaAndConflictDetection,
- updateApiSchema,
- createRandomName,
- generateModels,
- AmplifyFrontendConfig,
- AmplifyFrontend
+ initProjectWithProfile,
+ addApiWithBlankSchemaAndConflictDetection,
+ updateApiSchema,
+ createRandomName,
+ generateModels,
+ AmplifyFrontendConfig,
+ AmplifyFrontend,
} from '@aws-amplify/amplify-codegen-e2e-core';
-import { existsSync, writeFileSync } from "fs";
+import { existsSync, writeFileSync } from 'fs';
import path from 'path';
import { isNotEmptyDir, generateSourceCode } from '../utils';
const yaml = require('js-yaml');
export async function testCodegenModels(config: AmplifyFrontendConfig, projectRoot: string, schema: string, outputDir?: string) {
- const name = createRandomName();
+ const name = createRandomName();
- // init project and add API category
- await initProjectWithProfile(projectRoot, { name, ...config });
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { name, ...config });
- //enable datastore
- await addApiWithBlankSchemaAndConflictDetection(projectRoot);
- await updateApiSchema(projectRoot, name, schema);
+ //enable datastore
+ await addApiWithBlankSchemaAndConflictDetection(projectRoot);
+ await updateApiSchema(projectRoot, name, schema);
- //generate pre existing user file
- const userSourceCodePath = generateSourceCode(projectRoot, config.srcDir);
+ //generate pre existing user file
+ const userSourceCodePath = generateSourceCode(projectRoot, config.srcDir);
- // For flutter frontend, we need to have a pubspec lock file with supported dart version
- if (config?.frontendType === AmplifyFrontend.flutter) {
- createPubspecLockFile(projectRoot);
- }
+ // For flutter frontend, we need to have a pubspec lock file with supported dart version
+ if (config?.frontendType === AmplifyFrontend.flutter) {
+ createPubspecLockFile(projectRoot);
+ }
- //generate models
- await expect(generateModels(projectRoot, outputDir)).resolves.not.toThrow();
+ //generate models
+ await expect(generateModels(projectRoot, outputDir)).resolves.not.toThrow();
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
- // datastore models are generated at correct location
- const dirToCheck = outputDir
- ? path.join(projectRoot, outputDir)
- : path.join(projectRoot, config.modelgenDir);
- expect(isNotEmptyDir(dirToCheck)).toBe(true);
+ // datastore models are generated at correct location
+ const dirToCheck = outputDir ? path.join(projectRoot, outputDir) : path.join(projectRoot, config.modelgenDir);
+ expect(isNotEmptyDir(dirToCheck)).toBe(true);
}
export const createPubspecLockFile = (projectRoot: string) => {
- const lockFile = {
- packages: {
- amplify_flutter: {
- version: '2.0.0'
- },
- },
- };
- const pubspecPath = path.join(projectRoot, 'pubspec.lock');
- if (!existsSync(pubspecPath)) {
- writeFileSync(pubspecPath, yaml.dump(lockFile));
- }
+ const lockFile = {
+ packages: {
+ amplify_flutter: {
+ version: '2.0.0',
+ },
+ },
+ };
+ const pubspecPath = path.join(projectRoot, 'pubspec.lock');
+ if (!existsSync(pubspecPath)) {
+ writeFileSync(pubspecPath, yaml.dump(lockFile));
+ }
};
diff --git a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/graphql-codegen.ts b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/graphql-codegen.ts
index 4de1ad562..c240125a9 100644
--- a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/graphql-codegen.ts
+++ b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/graphql-codegen.ts
@@ -1,34 +1,34 @@
import {
- initProjectWithProfile,
- addApiWithoutSchema,
- updateApiSchema,
- addCodegen,
- AmplifyFrontendConfig,
- generateStatementsAndTypes,
- createRandomName
-} from "@aws-amplify/amplify-codegen-e2e-core";
-import { existsSync } from "fs";
+ initProjectWithProfile,
+ addApiWithoutSchema,
+ updateApiSchema,
+ addCodegen,
+ AmplifyFrontendConfig,
+ generateStatementsAndTypes,
+ createRandomName,
+} from '@aws-amplify/amplify-codegen-e2e-core';
+import { existsSync } from 'fs';
import path from 'path';
import { isNotEmptyDir, generateSourceCode } from '../utils';
export async function testGraphQLCodegen(config: AmplifyFrontendConfig, projectRoot: string, schema: string) {
- // init project and add API category
- await initProjectWithProfile(projectRoot, { ...config });
- const projectName = createRandomName();
- await addApiWithoutSchema(projectRoot, { apiName: projectName });
- await updateApiSchema(projectRoot, projectName, schema);
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { ...config });
+ const projectName = createRandomName();
+ await addApiWithoutSchema(projectRoot, { apiName: projectName });
+ await updateApiSchema(projectRoot, projectName, schema);
- // generate pre-existing user file
- const userSourceCodePath = generateSourceCode(projectRoot, config.srcDir);
+ // generate pre-existing user file
+ const userSourceCodePath = generateSourceCode(projectRoot, config.srcDir);
- // Add codegen
- await expect(addCodegen(projectRoot, { ...config })).resolves.not.toThrow();
+ // Add codegen
+ await expect(addCodegen(projectRoot, { ...config })).resolves.not.toThrow();
- // Execute GraphQL codegen
- await expect(generateStatementsAndTypes(projectRoot)).resolves.not.toThrow();
+ // Execute GraphQL codegen
+ await expect(generateStatementsAndTypes(projectRoot)).resolves.not.toThrow();
- // check if the pre-existing user file still exists
- expect(existsSync(userSourceCodePath)).toBe(true);
- // check if the statements are generated
- expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
+ // check if the pre-existing user file still exists
+ expect(existsSync(userSourceCodePath)).toBe(true);
+ // check if the statements are generated
+ expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
}
diff --git a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/push-codegen.ts b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/push-codegen.ts
index 20e65dc7d..26e1ecfce 100644
--- a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/push-codegen.ts
+++ b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/push-codegen.ts
@@ -1,78 +1,74 @@
import {
- initProjectWithProfile,
- addApiWithoutSchema,
- updateApiSchema,
- createRandomName,
- amplifyPushWithCodegenAdd,
- AmplifyFrontendConfig,
- amplifyPushWithCodegenUpdate,
- updateAPIWithResolutionStrategyWithModels,
- getProjectMeta,
- getDeploymentBucketObject,
- amplifyPush
-} from "@aws-amplify/amplify-codegen-e2e-core";
-import { existsSync } from "fs";
+ initProjectWithProfile,
+ addApiWithoutSchema,
+ updateApiSchema,
+ createRandomName,
+ amplifyPushWithCodegenAdd,
+ AmplifyFrontendConfig,
+ amplifyPushWithCodegenUpdate,
+ updateAPIWithResolutionStrategyWithModels,
+ getProjectMeta,
+ getDeploymentBucketObject,
+ amplifyPush,
+} from '@aws-amplify/amplify-codegen-e2e-core';
+import { existsSync } from 'fs';
import path from 'path';
import { isNotEmptyDir } from '../utils';
-import { testSetupBeforeAddCodegen } from "./test-setup";
+import { testSetupBeforeAddCodegen } from './test-setup';
export async function testPushCodegen(config: AmplifyFrontendConfig, projectRoot: string, schema: string) {
- // init project and add API category
- await initProjectWithProfile(projectRoot, { ...config });
- const projectName = createRandomName();
- await addApiWithoutSchema(projectRoot, { apiName: projectName });
- await updateApiSchema(projectRoot, projectName, schema);
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { ...config });
+ const projectName = createRandomName();
+ await addApiWithoutSchema(projectRoot, { apiName: projectName });
+ await updateApiSchema(projectRoot, projectName, schema);
- const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
+ const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
- // add codegen succeeds
- await amplifyPushWithCodegenAdd(projectRoot, { ...config });
+ // add codegen succeeds
+ await amplifyPushWithCodegenAdd(projectRoot, { ...config });
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
- // GraphQL statements are generated
- expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
+ // GraphQL statements are generated
+ expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
- //enable datastore
- await updateAPIWithResolutionStrategyWithModels(projectRoot, {});
- //push with codegen update
- await amplifyPushWithCodegenUpdate(projectRoot);
- expect(existsSync(userSourceCodePath)).toBe(true);
- expect(isNotEmptyDir(path.join(projectRoot, config.modelgenDir))).toBe(true);
+ //enable datastore
+ await updateAPIWithResolutionStrategyWithModels(projectRoot, {});
+ //push with codegen update
+ await amplifyPushWithCodegenUpdate(projectRoot);
+ expect(existsSync(userSourceCodePath)).toBe(true);
+ expect(isNotEmptyDir(path.join(projectRoot, config.modelgenDir))).toBe(true);
}
export async function testPushAdminModelgen(config: AmplifyFrontendConfig, projectRoot: string, schema: string) {
- // init project and add API category
- await initProjectWithProfile(projectRoot, { ...config, disableAmplifyAppCreation: false, });
- const {
- DeploymentBucketName: bucketName,
- Region: region,
- AmplifyAppId: appId,
- } = getProjectMeta(projectRoot).providers.awscloudformation;
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { ...config, disableAmplifyAppCreation: false });
+ const { DeploymentBucketName: bucketName, Region: region, AmplifyAppId: appId } = getProjectMeta(projectRoot).providers.awscloudformation;
- expect(bucketName).toBeDefined()
- expect(region).toBeDefined();
- expect(appId).toBeDefined();
+ expect(bucketName).toBeDefined();
+ expect(region).toBeDefined();
+ expect(appId).toBeDefined();
- const projectName = createRandomName();
- await addApiWithoutSchema(projectRoot, { apiName: projectName });
- await updateApiSchema(projectRoot, projectName, schema);
- // add codegen succeeds
- await amplifyPush(projectRoot);
+ const projectName = createRandomName();
+ await addApiWithoutSchema(projectRoot, { apiName: projectName });
+ await updateApiSchema(projectRoot, projectName, schema);
+ // add codegen succeeds
+ await amplifyPush(projectRoot);
- /**
- * Source code from
- * https://github.com/aws-amplify/amplify-cli/blob/1da5de70c57b15a76f02c92364af4889d1585229/packages/amplify-provider-awscloudformation/src/admin-modelgen.ts#L85-L93
- */
- const s3ApiModelsPrefix = `models/${projectName}/`;
- const cmsArtifactLocalToS3Keys = [
- `${s3ApiModelsPrefix}schema.graphql`,
- `${s3ApiModelsPrefix}schema.js`,
- `${s3ApiModelsPrefix}modelIntrospection.json`,
- ];
- // expect CMS assets to be present in S3
- cmsArtifactLocalToS3Keys.forEach(async (key) => {
- await expect(getDeploymentBucketObject(projectRoot, key)).resolves.not.toThrow();
- });
+ /**
+ * Source code from
+ * https://github.com/aws-amplify/amplify-cli/blob/1da5de70c57b15a76f02c92364af4889d1585229/packages/amplify-provider-awscloudformation/src/admin-modelgen.ts#L85-L93
+ */
+ const s3ApiModelsPrefix = `models/${projectName}/`;
+ const cmsArtifactLocalToS3Keys = [
+ `${s3ApiModelsPrefix}schema.graphql`,
+ `${s3ApiModelsPrefix}schema.js`,
+ `${s3ApiModelsPrefix}modelIntrospection.json`,
+ ];
+ // expect CMS assets to be present in S3
+ cmsArtifactLocalToS3Keys.forEach(async (key) => {
+ await expect(getDeploymentBucketObject(projectRoot, key)).resolves.not.toThrow();
+ });
}
diff --git a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/remove-codegen.ts b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/remove-codegen.ts
index 1c6d15b96..97dede1aa 100644
--- a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/remove-codegen.ts
+++ b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/remove-codegen.ts
@@ -1,38 +1,38 @@
import {
- initProjectWithProfile,
- addApiWithoutSchema,
- updateApiSchema,
- createRandomName,
- addCodegen,
- removeCodegen,
- AmplifyFrontendConfig
-} from "@aws-amplify/amplify-codegen-e2e-core";
-import { existsSync, readFileSync } from "fs";
+ initProjectWithProfile,
+ addApiWithoutSchema,
+ updateApiSchema,
+ createRandomName,
+ addCodegen,
+ removeCodegen,
+ AmplifyFrontendConfig,
+} from '@aws-amplify/amplify-codegen-e2e-core';
+import { existsSync, readFileSync } from 'fs';
import path from 'path';
import { isNotEmptyDir } from '../utils';
-import { testSetupBeforeAddCodegen, getGraphQLConfigFilePath } from "./test-setup";
+import { testSetupBeforeAddCodegen, getGraphQLConfigFilePath } from './test-setup';
import { load } from 'js-yaml';
export async function testRemoveCodegen(config: AmplifyFrontendConfig, projectRoot: string, schema: string) {
- // init project and add API category
- await initProjectWithProfile(projectRoot, { ...config });
- const projectName = createRandomName();
- await addApiWithoutSchema(projectRoot, { apiName: projectName });
- await updateApiSchema(projectRoot, projectName, schema);
+ // init project and add API category
+ await initProjectWithProfile(projectRoot, { ...config });
+ const projectName = createRandomName();
+ await addApiWithoutSchema(projectRoot, { apiName: projectName });
+ await updateApiSchema(projectRoot, projectName, schema);
- const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
+ const userSourceCodePath = testSetupBeforeAddCodegen(projectRoot, config);
- // add codegen succeeds
- await expect(addCodegen(projectRoot, { ...config })).resolves.not.toThrow();
+ // add codegen succeeds
+ await expect(addCodegen(projectRoot, { ...config })).resolves.not.toThrow();
- // remove codegen
- await expect(removeCodegen(projectRoot)).resolves.not.toThrow();
+ // remove codegen
+ await expect(removeCodegen(projectRoot)).resolves.not.toThrow();
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
- // previously generated files should still exist
- expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
- // graphql configuration should be updated to remove previous configuration
- const generatedConfig = load(readFileSync(getGraphQLConfigFilePath(projectRoot)).toString());
- expect(Object.keys(generatedConfig['projects']).length).toEqual(0);
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
+ // previously generated files should still exist
+ expect(isNotEmptyDir(path.join(projectRoot, config.graphqlCodegenDir))).toBe(true);
+ // graphql configuration should be updated to remove previous configuration
+ const generatedConfig = load(readFileSync(getGraphQLConfigFilePath(projectRoot)).toString());
+ expect(Object.keys(generatedConfig['projects']).length).toEqual(0);
}
diff --git a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/test-setup.ts b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/test-setup.ts
index 32e23c7e9..3f87d4e41 100644
--- a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/test-setup.ts
+++ b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/test-setup.ts
@@ -48,7 +48,7 @@ export async function testValidGraphQLConfig(
expect(existsSync(getGraphQLConfigFilePath(projectRoot))).toBe(true);
const generatedConfig = load(readFileSync(getGraphQLConfigFilePath(projectRoot)).toString());
- Object.keys(generatedConfig['projects']).forEach(projectName => {
+ Object.keys(generatedConfig['projects']).forEach((projectName) => {
const projectConfig = generatedConfig['projects'][projectName];
const expectedProjectConfig = constructGraphQLConfig(projectName, config, maxDepth, region, isConfigured);
// check if the graphql codegen configuration is valid
diff --git a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/uninitialized-modelgen.ts b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/uninitialized-modelgen.ts
index 609ec17e9..5ef8fe870 100644
--- a/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/uninitialized-modelgen.ts
+++ b/packages/amplify-codegen-e2e-tests/src/codegen-tests-base/uninitialized-modelgen.ts
@@ -5,66 +5,71 @@ import { createPubspecLockFile } from './datastore-modelgen';
import path from 'path';
export type TestUninitializedCodegenModelsProps = {
- config: AmplifyFrontendConfig;
- projectRoot: string;
- schemaName: string;
- shouldSucceed: boolean;
- outputDir?: string;
- featureFlags?: Record;
- expectedFilenames?: Array;
+ config: AmplifyFrontendConfig;
+ projectRoot: string;
+ schemaName: string;
+ shouldSucceed: boolean;
+ outputDir?: string;
+ featureFlags?: Record;
+ expectedFilenames?: Array;
};
export const testUninitializedCodegenModels = async ({
- config,
- projectRoot,
- schemaName,
- outputDir,
- shouldSucceed,
- featureFlags,
- expectedFilenames,
+ config,
+ projectRoot,
+ schemaName,
+ outputDir,
+ shouldSucceed,
+ featureFlags,
+ expectedFilenames,
}: TestUninitializedCodegenModelsProps): Promise => {
- // generate pre existing user file
- const userSourceCodePath = generateSourceCode(projectRoot, config.srcDir);
+ // generate pre existing user file
+ const userSourceCodePath = generateSourceCode(projectRoot, config.srcDir);
- // Write Schema File to Schema Path
- const schemaPath = getSchemaPath(schemaName);
- const schema = readFileSync(schemaPath).toString();
- const modelSchemaPath = path.join(config.srcDir, 'schema.graphql');
- writeFileSync(path.join(projectRoot, modelSchemaPath), schema);
+ // Write Schema File to Schema Path
+ const schemaPath = getSchemaPath(schemaName);
+ const schema = readFileSync(schemaPath).toString();
+ const modelSchemaPath = path.join(config.srcDir, 'schema.graphql');
+ writeFileSync(path.join(projectRoot, modelSchemaPath), schema);
- // For flutter frontend, we need to have a pubspec lock file with supported dart version
- if (config?.frontendType === AmplifyFrontend.flutter) {
- createPubspecLockFile(projectRoot);
- }
+ // For flutter frontend, we need to have a pubspec lock file with supported dart version
+ if (config?.frontendType === AmplifyFrontend.flutter) {
+ createPubspecLockFile(projectRoot);
+ }
- // generate models
- try {
- await generateModelsWithOptions(projectRoot, {
- '--target': config.frontendType,
- '--model-schema': modelSchemaPath,
- '--output-dir': outputDir,
- ...(featureFlags ? Object.entries(featureFlags).map(([ffName, ffVal]) => [`--feature-flag:${ffName}`, ffVal]).flat() : []),
- });
- } catch (_) {
- // This is temporarily expected to throw, since the post-modelgen hook in amplify cli fails, even though modelgen succeeds.
- }
+ // generate models
+ try {
+ await generateModelsWithOptions(projectRoot, {
+ '--target': config.frontendType,
+ '--model-schema': modelSchemaPath,
+ '--output-dir': outputDir,
+ ...(featureFlags
+ ? Object.entries(featureFlags)
+ .map(([ffName, ffVal]) => [`--feature-flag:${ffName}`, ffVal])
+ .flat()
+ : []),
+ });
+ } catch (_) {
+ // This is temporarily expected to throw, since the post-modelgen hook in amplify cli fails, even though modelgen succeeds.
+ }
- // pre-existing file should still exist
- expect(existsSync(userSourceCodePath)).toBe(true);
+ // pre-existing file should still exist
+ expect(existsSync(userSourceCodePath)).toBe(true);
- // datastore models are generated at correct location
- const partialDirToCheck = outputDir
- ? path.join(projectRoot, outputDir)
- : path.join(projectRoot, config.modelgenDir);
- const dirToCheck = config.frontendType === AmplifyFrontend.android
- ? path.join(partialDirToCheck, 'com', 'amplifyframework', 'datastore', 'generated', 'model')
- : partialDirToCheck;
+ // datastore models are generated at correct location
+ const partialDirToCheck = outputDir ? path.join(projectRoot, outputDir) : path.join(projectRoot, config.modelgenDir);
+ const dirToCheck =
+ config.frontendType === AmplifyFrontend.android
+ ? path.join(partialDirToCheck, 'com', 'amplifyframework', 'datastore', 'generated', 'model')
+ : partialDirToCheck;
- expect(isNotEmptyDir(dirToCheck)).toBe(shouldSucceed);
+ expect(isNotEmptyDir(dirToCheck)).toBe(shouldSucceed);
- if (expectedFilenames) {
- const foundFiles = new Set(readdirSync(dirToCheck));
- console.log(`Comparing written files: ${JSON.stringify(Array.from(foundFiles))} to expected files: ${JSON.stringify(expectedFilenames)}`);
- expectedFilenames.forEach((expectedFilename) => expect(foundFiles.has(expectedFilename)).toBe(true));
- }
+ if (expectedFilenames) {
+ const foundFiles = new Set(readdirSync(dirToCheck));
+ console.log(
+ `Comparing written files: ${JSON.stringify(Array.from(foundFiles))} to expected files: ${JSON.stringify(expectedFilenames)}`,
+ );
+ expectedFilenames.forEach((expectedFilename) => expect(foundFiles.has(expectedFilename)).toBe(true));
+ }
};
diff --git a/packages/amplify-codegen-e2e-tests/src/configure_tests.ts b/packages/amplify-codegen-e2e-tests/src/configure_tests.ts
index 9d04364fb..e9e2757e2 100644
--- a/packages/amplify-codegen-e2e-tests/src/configure_tests.ts
+++ b/packages/amplify-codegen-e2e-tests/src/configure_tests.ts
@@ -18,8 +18,7 @@ async function setupAmplify() {
if (process.env.AWS_SESSION_TOKEN) {
injectSessionToken('amplify-integ-test-user');
}
- }
- else {
+ } else {
console.log('AWS Profile is already configured');
}
}
diff --git a/packages/amplify-codegen-e2e-tests/src/environment/env.ts b/packages/amplify-codegen-e2e-tests/src/environment/env.ts
index 4c5dc1a28..53dd5a622 100644
--- a/packages/amplify-codegen-e2e-tests/src/environment/env.ts
+++ b/packages/amplify-codegen-e2e-tests/src/environment/env.ts
@@ -46,7 +46,7 @@ export function addEnvironmentWithImportedAuth(cwd: string, settings: { envName:
});
}
-export function checkoutEnvironment(cwd: string, settings: { envName: string, withRestore?: boolean }): Promise {
+export function checkoutEnvironment(cwd: string, settings: { envName: string; withRestore?: boolean }): Promise {
const args = ['env', 'checkout', settings.envName];
if (settings.withRestore) {
args.push('--restore');
@@ -88,7 +88,7 @@ export function listEnvironment(cwd: string, settings: { numEnv?: number }): Pro
// Get environment details and return them as JSON
export function getEnvironment(cwd: string, settings: { envName: string }): Promise {
const envData = {};
- let helper = output => {
+ let helper = (output) => {
let keyVal = output.split(/:(.+)/); // Split string on first ':' only
envData[keyVal[0].trim()] = keyVal[1].trim();
};
diff --git a/packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/commands.ts b/packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/commands.ts
index 30351502b..78cda1880 100644
--- a/packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/commands.ts
+++ b/packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/commands.ts
@@ -16,13 +16,8 @@ const getNpxPath = (): string => (process.platform === 'win32' ? getScriptRunner
const getAmpxPath = (cwd: string): string =>
spawnSync(getNpxPath(), ['which', 'ampx'], { cwd, env: process.env, stdio: 'pipe' }).stdout.toString().trim();
-const codegenPackagesInGen2 = [
- '@aws-amplify/graphql-generator',
- '@aws-amplify/graphql-types-generator'
-];
-const apiPackagesInGen2 = [
- '@aws-amplify/data-construct'
-];
+const codegenPackagesInGen2 = ['@aws-amplify/graphql-generator', '@aws-amplify/graphql-types-generator'];
+const apiPackagesInGen2 = ['@aws-amplify/data-construct'];
type CodegenPackage = 'GraphqlGenerator' | 'TypeGen';
@@ -51,7 +46,7 @@ export const initGen2Project = async (cwd: string, templatePath: string, props:
cwd,
stripColors: true,
};
- const npmPath = getCommandPath('npm')
+ const npmPath = getCommandPath('npm');
await spawn(npmPath, ['create', 'amplify@latest', '-y'], commandOptions).runAsync();
overrideWithLocalCodegenPackages(cwd);
@@ -98,53 +93,51 @@ export const sandboxDeploy = async (cwd: string, props: Gen2DeployProps = {}): P
* On windows, the Ctrl-C signal is not returned correctly from npx binary, whose code is 1 and will fail nexpect check
* Therefore, the ampx binary is used for sandbox deployment instead of npx
*/
- const ampxCli = getAmpxPath(cwd)
- await
- spawn(ampxCli, ['sandbox'], commandOptions)
- .wait('Watching for file changes...')
- .sendCtrlC()
- .wait('Would you like to delete all the resources in your sandbox environment')
- .sendLine('N')
- .runAsync();
+ const ampxCli = getAmpxPath(cwd);
+ await spawn(ampxCli, ['sandbox'], commandOptions)
+ .wait('Watching for file changes...')
+ .sendCtrlC()
+ .wait('Would you like to delete all the resources in your sandbox environment')
+ .sendLine('N')
+ .runAsync();
};
export const deleteSandbox = async (cwd: string): Promise => {
- await
- spawn(getNpxPath(), ['ampx', 'sandbox', 'delete'], { cwd, stripColors: true })
- .wait('Are you sure you want to delete all the resources in your sandbox environment')
- .sendLine('Y')
- .runAsync();
+ await spawn(getNpxPath(), ['ampx', 'sandbox', 'delete'], { cwd, stripColors: true })
+ .wait('Are you sure you want to delete all the resources in your sandbox environment')
+ .sendLine('Y')
+ .runAsync();
};
/**
* Commands for ampx generate
*/
export type ClientCodegenConfigBase = {
- format: string
- outDir: string
-}
+ format: string;
+ outDir: string;
+};
export type IntrospectionCodegenConfig = ClientCodegenConfigBase & {
- format: 'introspection'
-}
+ format: 'introspection';
+};
export type ModelgenConfig = ClientCodegenConfigBase & {
- format: 'modelgen'
- modelTarget: string
-}
+ format: 'modelgen';
+ modelTarget: string;
+};
export type GraphqlCodegenConfig = ClientCodegenConfigBase & {
- format: 'graphql-codegen'
- typeTarget: string
- statementTarget: string
-}
-export type ClientCodegenConfig = IntrospectionCodegenConfig | ModelgenConfig | GraphqlCodegenConfig
+ format: 'graphql-codegen';
+ typeTarget: string;
+ statementTarget: string;
+};
+export type ClientCodegenConfig = IntrospectionCodegenConfig | ModelgenConfig | GraphqlCodegenConfig;
const getClientCodegenParams = (props: ClientCodegenConfig): string[] => {
- const params = [ '--out', props.outDir, '--format', props.format ]
+ const params = ['--out', props.outDir, '--format', props.format];
switch (props.format) {
case 'modelgen':
- return [ ...params, '--model-target', props.modelTarget];
+ return [...params, '--model-target', props.modelTarget];
case 'graphql-codegen':
- return [ ...params, '--type-target', props.typeTarget, '--statement-target', props.statementTarget]
+ return [...params, '--type-target', props.typeTarget, '--statement-target', props.statementTarget];
case 'introspection':
default:
return params;
@@ -152,28 +145,16 @@ const getClientCodegenParams = (props: ClientCodegenConfig): string[] => {
};
export const generateGraphqlClientCode = async (cwd: string, props: ClientCodegenConfig): Promise => {
- await
- spawn(
- getNpxPath(),
- ['ampx', 'generate', 'graphql-client-code', ...getClientCodegenParams(props)],
- { cwd, stripColors: true },
- ).runAsync();
+ await spawn(getNpxPath(), ['ampx', 'generate', 'graphql-client-code', ...getClientCodegenParams(props)], {
+ cwd,
+ stripColors: true,
+ }).runAsync();
};
export const generateForms = async (cwd: string, props: any = {}): Promise => {
- await
- spawn(
- getNpxPath(),
- ['ampx', 'generate', 'forms'],
- { cwd, stripColors: true },
- ).runAsync();
+ await spawn(getNpxPath(), ['ampx', 'generate', 'forms'], { cwd, stripColors: true }).runAsync();
};
export const generateOutputs = async (cwd: string, props: any = {}): Promise => {
- await
- spawn(
- getNpxPath(),
- ['ampx', 'generate', 'outputs'],
- { cwd, stripColors: true },
- ).runAsync();
+ await spawn(getNpxPath(), ['ampx', 'generate', 'outputs'], { cwd, stripColors: true }).runAsync();
};
diff --git a/packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/test-graphql-client-codegen.ts b/packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/test-graphql-client-codegen.ts
index 0ad0209a2..f2133cdf8 100644
--- a/packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/test-graphql-client-codegen.ts
+++ b/packages/amplify-codegen-e2e-tests/src/gen2-codegen-tests-base/test-graphql-client-codegen.ts
@@ -1,11 +1,11 @@
import path from 'path';
-import { isNotEmptyDir } from "../utils";
-import { ClientCodegenConfig, generateGraphqlClientCode } from "./commands";
+import { isNotEmptyDir } from '../utils';
+import { ClientCodegenConfig, generateGraphqlClientCode } from './commands';
import { existsSync } from 'fs-extra';
import { deleteProjectDir } from '@aws-amplify/amplify-codegen-e2e-core';
export const testGraphqlClientCodegen = async (projectRoot: string, config: ClientCodegenConfig) => {
- const outputPath = path.join(projectRoot, config.outDir)
+ const outputPath = path.join(projectRoot, config.outDir);
if (existsSync(outputPath)) {
deleteProjectDir(outputPath);
}
diff --git a/packages/amplify-codegen-e2e-tests/src/import-helpers/expects.ts b/packages/amplify-codegen-e2e-tests/src/import-helpers/expects.ts
index 39c3881ab..22f4cc38f 100644
--- a/packages/amplify-codegen-e2e-tests/src/import-helpers/expects.ts
+++ b/packages/amplify-codegen-e2e-tests/src/import-helpers/expects.ts
@@ -38,12 +38,12 @@ export const expectAuthLocalAndOGMetaFilesOutputMatching = (projectRoot: string,
const ogMeta = getBackendAmplifyMeta(ogProjectRoot);
const authMeta = Object.keys(meta.auth)
- .filter(key => meta.auth[key].service === 'Cognito')
- .map(key => meta.auth[key])[0];
+ .filter((key) => meta.auth[key].service === 'Cognito')
+ .map((key) => meta.auth[key])[0];
const ogAuthMeta = Object.keys(ogMeta.auth)
- .filter(key => ogMeta.auth[key].service === 'Cognito')
- .map(key => ogMeta.auth[key])[0];
+ .filter((key) => ogMeta.auth[key].service === 'Cognito')
+ .map((key) => ogMeta.auth[key])[0];
expect(authMeta.output.AppClientID).toEqual(ogAuthMeta.output.AppClientID);
expect(authMeta.output.AppClientIDWeb).toEqual(ogAuthMeta.output.AppClientIDWeb);
@@ -116,12 +116,12 @@ export const expectS3LocalAndOGMetaFilesOutputMatching = (projectRoot: string, o
const ogMeta = getBackendAmplifyMeta(ogProjectRoot);
const storageMeta = Object.keys(meta.storage)
- .filter(key => meta.storage[key].service === 'S3')
- .map(key => meta.storage[key])[0];
+ .filter((key) => meta.storage[key].service === 'S3')
+ .map((key) => meta.storage[key])[0];
const ogStorageMeta = Object.keys(ogMeta.storage)
- .filter(key => ogMeta.storage[key].service === 'S3')
- .map(key => ogMeta.storage[key])[0];
+ .filter((key) => ogMeta.storage[key].service === 'S3')
+ .map((key) => ogMeta.storage[key])[0];
expect(storageMeta.output.BucketName).toEqual(ogStorageMeta.output.BucketName);
expect(storageMeta.output.Region).toEqual(ogStorageMeta.output.Region);
@@ -152,12 +152,12 @@ export const expectDynamoDBLocalAndOGMetaFilesOutputMatching = (projectRoot: str
const ogMeta = getBackendAmplifyMeta(ogProjectRoot);
const storageMeta = Object.keys(meta.storage)
- .filter(key => meta.storage[key].service === 'DynamoDB')
- .map(key => meta.storage[key])[0];
+ .filter((key) => meta.storage[key].service === 'DynamoDB')
+ .map((key) => meta.storage[key])[0];
const ogStorageMeta = Object.keys(ogMeta.storage)
- .filter(key => ogMeta.storage[key].service === 'DynamoDB')
- .map(key => ogMeta.storage[key])[0];
+ .filter((key) => ogMeta.storage[key].service === 'DynamoDB')
+ .map((key) => ogMeta.storage[key])[0];
expect(storageMeta.output.Name).toEqual(ogStorageMeta.output.Name);
expect(storageMeta.output.Region).toEqual(ogStorageMeta.output.Region);
diff --git a/packages/amplify-codegen-e2e-tests/src/import-helpers/utilities.ts b/packages/amplify-codegen-e2e-tests/src/import-helpers/utilities.ts
index 785fd9f13..c7a07c589 100644
--- a/packages/amplify-codegen-e2e-tests/src/import-helpers/utilities.ts
+++ b/packages/amplify-codegen-e2e-tests/src/import-helpers/utilities.ts
@@ -20,8 +20,8 @@ export const getAuthProjectDetails = (projectRoot: string): AuthProjectDetails =
const team = getTeamProviderInfo(projectRoot);
const authMetaKey = Object.keys(meta.auth)
- .filter(key => meta.auth[key].service === 'Cognito')
- .map(key => key)[0];
+ .filter((key) => meta.auth[key].service === 'Cognito')
+ .map((key) => key)[0];
const authMeta = meta.auth[authMetaKey];
const authTeam = _.get(team, ['integtest', 'categories', 'auth', authMetaKey]);
@@ -85,8 +85,8 @@ export const getOGAuthProjectDetails = (projectRoot: string): AuthProjectDetails
const team = getTeamProviderInfo(projectRoot);
const authMetaKey = Object.keys(meta.auth)
- .filter(key => meta.auth[key].service === 'Cognito')
- .map(key => key)[0];
+ .filter((key) => meta.auth[key].service === 'Cognito')
+ .map((key) => key)[0];
const authMeta = meta.auth[authMetaKey];
const authTeam = _.get(team, ['integtest', 'categories', 'auth', authMetaKey]);
@@ -135,8 +135,8 @@ export const getOGStorageProjectDetails = (projectRoot: string): StorageProjectD
const meta = getBackendAmplifyMeta(projectRoot);
const storageMetaKey = Object.keys(meta.storage)
- .filter(key => meta.storage[key].service === 'S3')
- .map(key => key)[0];
+ .filter((key) => meta.storage[key].service === 'S3')
+ .map((key) => key)[0];
const storageMeta = meta.storage[storageMetaKey];
const parameters = readResourceParametersJson(projectRoot, 'storage', storageMetaKey);
@@ -158,8 +158,8 @@ export const getStorageProjectDetails = (projectRoot: string): StorageProjectDet
const team = getTeamProviderInfo(projectRoot);
const storageMetaKey = Object.keys(meta.storage)
- .filter(key => meta.storage[key].service === 'S3')
- .map(key => key)[0];
+ .filter((key) => meta.storage[key].service === 'S3')
+ .map((key) => key)[0];
const stoargeMeta = meta.storage[storageMetaKey];
const storageTeam = _.get(team, ['integtest', 'categories', 'storage', storageMetaKey]);
@@ -195,8 +195,8 @@ export const getOGDynamoDBProjectDetails = (projectRoot: string): DynamoDBProjec
const meta = getBackendAmplifyMeta(projectRoot);
const storageMetaKey = Object.keys(meta.storage)
- .filter(key => meta.storage[key].service === 'DynamoDB')
- .map(key => key)[0];
+ .filter((key) => meta.storage[key].service === 'DynamoDB')
+ .map((key) => key)[0];
const storageMeta = meta.storage[storageMetaKey];
const parameters = readResourceParametersJson(projectRoot, 'storage', storageMetaKey);
@@ -224,8 +224,8 @@ export const getDynamoDBProjectDetails = (projectRoot: string): DynamoDBProjectD
const team = getTeamProviderInfo(projectRoot);
const storageMetaKey = Object.keys(meta.storage)
- .filter(key => meta.storage[key].service === 'DynamoDB')
- .map(key => key)[0];
+ .filter((key) => meta.storage[key].service === 'DynamoDB')
+ .map((key) => key)[0];
const dynamodbMeta = meta.storage[storageMetaKey];
const storageTeam = _.get(team, ['integtest', 'categories', 'storage', storageMetaKey]);
diff --git a/packages/amplify-codegen-e2e-tests/src/init-special-cases/index.ts b/packages/amplify-codegen-e2e-tests/src/init-special-cases/index.ts
index 0490c7ffa..0de81f0d2 100644
--- a/packages/amplify-codegen-e2e-tests/src/init-special-cases/index.ts
+++ b/packages/amplify-codegen-e2e-tests/src/init-special-cases/index.ts
@@ -1,5 +1,12 @@
import path from 'path';
-import { nspawn as spawn, getCLIPath, singleSelect, amplifyRegions, addCITags, KEY_DOWN_ARROW } from '@aws-amplify/amplify-codegen-e2e-core';
+import {
+ nspawn as spawn,
+ getCLIPath,
+ singleSelect,
+ amplifyRegions,
+ addCITags,
+ KEY_DOWN_ARROW,
+} from '@aws-amplify/amplify-codegen-e2e-core';
import fs from 'fs-extra';
import os from 'os';
diff --git a/packages/amplify-codegen-e2e-tests/src/schema-api-directives/authHelper.ts b/packages/amplify-codegen-e2e-tests/src/schema-api-directives/authHelper.ts
index 6578d7627..eb03bc3f5 100644
--- a/packages/amplify-codegen-e2e-tests/src/schema-api-directives/authHelper.ts
+++ b/packages/amplify-codegen-e2e-tests/src/schema-api-directives/authHelper.ts
@@ -184,13 +184,13 @@ export async function signInUser2(username: string, realPw: string) {
export async function authenticateUser(user: any, details: any, realPw: string) {
return new Promise((res, rej) => {
user.authenticateUser(details, {
- onSuccess: function(result: any) {
+ onSuccess: function (result: any) {
res(result);
},
- onFailure: function(err: any) {
+ onFailure: function (err: any) {
rej(err);
},
- newPasswordRequired: function(userAttributes: any, requiredAttributes: any) {
+ newPasswordRequired: function (userAttributes: any, requiredAttributes: any) {
user.completeNewPasswordChallenge(realPw, user.Attributes, this);
},
});
diff --git a/packages/amplify-codegen-e2e-tests/src/schema-api-directives/common.ts b/packages/amplify-codegen-e2e-tests/src/schema-api-directives/common.ts
index 05e122867..7afaa4801 100644
--- a/packages/amplify-codegen-e2e-tests/src/schema-api-directives/common.ts
+++ b/packages/amplify-codegen-e2e-tests/src/schema-api-directives/common.ts
@@ -83,7 +83,7 @@ export function updateSchemaInTestProject(projectDir: string, schema: any) {
}
export async function testMutations(testModule: any, appSyncClient: any) {
- let mutationNames = Object.keys(testModule).filter(key => /^mutation[0-9]*$/.test(key));
+ let mutationNames = Object.keys(testModule).filter((key) => /^mutation[0-9]*$/.test(key));
if (mutationNames.length > 1) {
mutationNames = mutationNames.sort((name1, name2) => {
@@ -94,7 +94,7 @@ export async function testMutations(testModule: any, appSyncClient: any) {
}
const mutationTasks = [];
- mutationNames.forEach(mutationName => {
+ mutationNames.forEach((mutationName) => {
const mutation = testModule[mutationName];
const mutationInput = testModule['input_' + mutationName];
const mutationResult = testModule['expected_result_' + mutationName];
@@ -145,7 +145,7 @@ export async function testMutation(appSyncClient: any, mutation: any, mutationIn
}
export async function testQueries(testModule: any, appSyncClient: any) {
- let queryNames = Object.keys(testModule).filter(key => /^query[0-9]*$/.test(key));
+ let queryNames = Object.keys(testModule).filter((key) => /^query[0-9]*$/.test(key));
if (queryNames.length > 1) {
queryNames = queryNames.sort((name1, name2) => {
@@ -156,7 +156,7 @@ export async function testQueries(testModule: any, appSyncClient: any) {
}
const queryTasks = [];
- queryNames.forEach(queryName => {
+ queryNames.forEach((queryName) => {
const query = testModule[queryName];
const queryInput = testModule['input_' + queryName];
const queryResult = testModule['expected_result_' + queryName];
@@ -206,7 +206,7 @@ export async function testQuery(appSyncClient: any, query: any, queryInput?: any
}
export async function testSubscriptions(testModule: any, appsyncClient: any) {
- let subscriptionNames = Object.keys(testModule).filter(key => /^subscription[0-9]*$/.test(key));
+ let subscriptionNames = Object.keys(testModule).filter((key) => /^subscription[0-9]*$/.test(key));
if (subscriptionNames.length > 1) {
subscriptionNames = subscriptionNames.sort((name1, name2) => {
@@ -217,7 +217,7 @@ export async function testSubscriptions(testModule: any, appsyncClient: any) {
}
const subscriptionTasks = [];
- subscriptionNames.forEach(subscriptionName => {
+ subscriptionNames.forEach((subscriptionName) => {
const subscription = testModule[subscriptionName];
const subscriptionInput = testModule['input_' + subscriptionName];
const subscriptionResult = testModule['expected_result_' + subscriptionName];
@@ -250,7 +250,7 @@ export async function testSubscription(
received.push(event.data);
});
- await new Promise(res => setTimeout(() => res(), 4000));
+ await new Promise((res) => setTimeout(() => res(), 4000));
const mutationTasks = [];
for (let i = 0; i < mutations.length; i++) {
@@ -262,13 +262,13 @@ export async function testSubscription(
fetchPolicy: 'no-cache',
variables: mutationInput,
});
- await new Promise(res => setTimeout(() => res(), 4000)); //to ensure correct order in received data
+ await new Promise((res) => setTimeout(() => res(), 4000)); //to ensure correct order in received data
});
}
await runInSequential(mutationTasks);
- await new Promise(res => setTimeout(() => res(), 4000));
+ await new Promise((res) => setTimeout(() => res(), 4000));
sub.unsubscribe();
if (!checkResult(received, subscriptionResult)) {
@@ -335,7 +335,7 @@ function runCompare(queue: { received: any; expected: any; depth: number }[]): b
} else if (itemToCompare.received === null) {
result = false;
} else if (typeof itemToCompare.received === 'object') {
- Object.keys(itemToCompare.expected).forEach(key => {
+ Object.keys(itemToCompare.expected).forEach((key) => {
queue.push({
received: itemToCompare.received[key],
expected: itemToCompare.expected[key],
diff --git a/packages/amplify-codegen-e2e-tests/src/schema-api-directives/tests/auth-usingOidc.ts b/packages/amplify-codegen-e2e-tests/src/schema-api-directives/tests/auth-usingOidc.ts
index b93a7e90c..0c40a2872 100644
--- a/packages/amplify-codegen-e2e-tests/src/schema-api-directives/tests/auth-usingOidc.ts
+++ b/packages/amplify-codegen-e2e-tests/src/schema-api-directives/tests/auth-usingOidc.ts
@@ -1,4 +1,10 @@
-import { addAuthWithDefault, amplifyPushWithoutCodegen, addApi, updateAuthAddUserGroups, amplifyPush } from '@aws-amplify/amplify-codegen-e2e-core';
+import {
+ addAuthWithDefault,
+ amplifyPushWithoutCodegen,
+ addApi,
+ updateAuthAddUserGroups,
+ amplifyPush,
+} from '@aws-amplify/amplify-codegen-e2e-core';
import {
getAppClientIDWeb,
diff --git a/packages/amplify-codegen-e2e-tests/src/schema-api-directives/tests/searchable-usage.ts b/packages/amplify-codegen-e2e-tests/src/schema-api-directives/tests/searchable-usage.ts
index 72b844616..97ea6084c 100644
--- a/packages/amplify-codegen-e2e-tests/src/schema-api-directives/tests/searchable-usage.ts
+++ b/packages/amplify-codegen-e2e-tests/src/schema-api-directives/tests/searchable-usage.ts
@@ -8,14 +8,14 @@ export async function runTest(projectDir: string, testModule: any) {
await addApi(projectDir);
updateSchemaInTestProject(projectDir, testModule.schema);
await amplifyPush(projectDir);
- await new Promise(res => setTimeout(() => res(), 60000));
+ await new Promise((res) => setTimeout(() => res(), 60000));
const awsconfig = configureAmplify(projectDir);
const apiKey = getApiKey(projectDir);
const appSyncClient = getConfiguredAppsyncClientAPIKeyAuth(awsconfig.aws_appsync_graphqlEndpoint, awsconfig.aws_appsync_region, apiKey);
await testMutations(testModule, appSyncClient);
- await new Promise(res => setTimeout(() => res(), 60000));
+ await new Promise((res) => setTimeout(() => res(), 60000));
await testQueries(testModule, appSyncClient);
}
diff --git a/packages/amplify-codegen-e2e-tests/src/utils/index.ts b/packages/amplify-codegen-e2e-tests/src/utils/index.ts
index b48492ad6..fffc8509a 100644
--- a/packages/amplify-codegen-e2e-tests/src/utils/index.ts
+++ b/packages/amplify-codegen-e2e-tests/src/utils/index.ts
@@ -1,16 +1,16 @@
-import { existsSync, writeFileSync, readdirSync, mkdirSync } from "fs";
+import { existsSync, writeFileSync, readdirSync, mkdirSync } from 'fs';
import path from 'path';
-export function isNotEmptyDir(dirPath: string) : boolean {
+export function isNotEmptyDir(dirPath: string): boolean {
return existsSync(dirPath) && readdirSync(dirPath).length > 0;
}
-export function generateSourceCode(projectRoot: string, srcDir: string) : string {
+export function generateSourceCode(projectRoot: string, srcDir: string): string {
const userFileData = 'This is a pre-existing file.';
const srcCodePath = path.join(projectRoot, srcDir, 'sample.txt');
if (!existsSync(path.dirname(srcCodePath))) {
- mkdirSync(path.dirname(srcCodePath), {recursive: true});
+ mkdirSync(path.dirname(srcCodePath), { recursive: true });
}
writeFileSync(srcCodePath, userFileData);
return srcCodePath;
-}
\ No newline at end of file
+}
diff --git a/packages/amplify-codegen-e2e-tests/test-apps/docsgen-react-app/cypress.config.js b/packages/amplify-codegen-e2e-tests/test-apps/docsgen-react-app/cypress.config.js
index c092825ec..e77222239 100644
--- a/packages/amplify-codegen-e2e-tests/test-apps/docsgen-react-app/cypress.config.js
+++ b/packages/amplify-codegen-e2e-tests/test-apps/docsgen-react-app/cypress.config.js
@@ -1,10 +1,10 @@
-const { defineConfig } = require("cypress");
+const { defineConfig } = require('cypress');
module.exports = defineConfig({
component: {
devServer: {
- framework: "create-react-app",
- bundler: "webpack",
+ framework: 'create-react-app',
+ bundler: 'webpack',
},
},
});
diff --git a/packages/amplify-codegen-e2e-tests/test-apps/docsgen-react-app/cypress/support/component-index.html b/packages/amplify-codegen-e2e-tests/test-apps/docsgen-react-app/cypress/support/component-index.html
index ac6e79fd8..e39ba4296 100644
--- a/packages/amplify-codegen-e2e-tests/test-apps/docsgen-react-app/cypress/support/component-index.html
+++ b/packages/amplify-codegen-e2e-tests/test-apps/docsgen-react-app/cypress/support/component-index.html
@@ -1,12 +1,12 @@
-
-
-
+
+
+
Components App
-
\ No newline at end of file
+