appsync_lambda_main!() { /* proc-macro */ }
Expand description
Generates the code required to handle AWS AppSync Direct Lambda resolver events based on a GraphQL schema.
This macro takes a path to a GraphQL schema file and generates the complete foundation for implementing an AWS AppSync Direct Lambda resolver:
- Rust types for all GraphQL types (enums, inputs, objects)
- Query/Mutation/Subscription operation enums
- AWS Lambda runtime setup with logging to handle the AWS AppSync event
- Optional AWS SDK client initialization
§Example Usage
ⓘ
use lambda_appsync::appsync_lambda_main;
// If the function returns Some(AppsyncResponse), the Lambda function will immediatly return it
// Else, the normal flow of the AppSync operation processing will continue
// This is primarily intended for advanced authentication checks that AppSync cannot perform,
// such as verifying that a user is requesting their own ID for example.
async fn before_request(
event: &lambda_appsync::AppsyncEvent<Operation>
) -> Option<lambda_appsync::AppsyncResponse> {
todo!()
}
appsync_lambda_main!(
// Path to GraphQL schema file
"path/to/schema.gql",
// Optional AWS SDK clients
dynamodb() -> aws_sdk_dynamodb::Client,
s3() -> aws_sdk_s3::Client,
// Options
batch = true, // Enable batch request handling
hook = before_request, // Add custom request hook, typically used for authentication
field_type_override = MyType.field: CustomType // Override generated field types
);