pollen.tech-appsync-codegen
v0.0.3
Published
Pollen Appsync Codegen for development use
Downloads
2
Readme
Pollen Core AppSync
This project contains AppSync deployment and resolvers for AppSync APIs
Requirements
- Terraform
Add / Update AWS AppSync Configuration
Add or update schema on
schema.graphql
located on./appsync/schema.graphql
Add or update AppSync Resolver located on
./terraform/modules/appsync/resolvers
. Note: 1 Folder per resolverCreate resolver with minimum file requirement as follows:
└── resolvers (main resolver folder)/ └── your-resolver/ ├── resolvers/ │ ├── request.vtl │ └── response.vtl ├── main.tf └── variable.tf
main.tf
contains AppSync Resolver and Datasource configurationresource "aws_appsync_datasource" "<datasource name>" { name = <datasource name> api_id = var.api_id type = <datasource_type> service_role_arn = var.appsync.iam_role_arn lambda_config { function_arn = <AWS Lambda ARN> } } # Create resolver using the velocity templates in /resolvers/lambda. resource "aws_appsync_resolver" "<resolver name>" { api_id = var.api_id type = <resolver for schema type> field = <resolved field> data_source = aws_appsync_datasource.get_catalog.name request_template = file("${path.module}/resolvers/request.vtl") response_template = file("${path.module}/resolvers/response.vtl") }
variable.tf
contains variable that used by main.tfvariable "api_id" { default = "" description = "appsync api id" } variable "appsync" { description = "appsync properties" }
New files or new configuration inside those files can be added as needed
Add your AppSync resolver on
main.tf
file insidemodules/appsync
folder. Open./terraform/modules/appsync/main.tf
# ... # ... # ... module "<your new resolver>" { source = "./resolvers/<your new resolver on ./terraform/modules/appsync/resolvers>" api_id = aws_appsync_graphql_api.staging.id appsync = var.appsync }