Skip to content

Commit 894cebb

Browse files
committed
v0.10.0: composable macro architecture with Handlers trait
Replace monolithic code generation with three independent composable macros macro. Users now own main() and initialization concerns, enabling composition with Tower layers and external middleware. Breaking: remove main()/log-init generation, empty default features, #[appsync_operation] preserves original function, legacy options moved behind compat feature. Deprecate appsync_lambda_main! (now in compat). Add Handlers trait, default_traits/derive/type_module/operation_type/ error_logging options, const fn index()/all(), AppsyncResponse getters, per-operation tracing spans in batch handler, and core dependency re-exports.
1 parent 0425e55 commit 894cebb

89 files changed

Lines changed: 7652 additions & 2332 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.10.0] - 2026-03-31
9+
10+
### Added
11+
- **New composable macro architecture**: three independent macros that can be used individually or together:
12+
- `make_types!` — generates Rust structs and enums from GraphQL type/input/enum definitions
13+
- `make_operation!` — generates the `Operation` enum, sub-enums (`QueryField`, `MutationField`, `SubscriptionField`), and the `execute` dispatch method
14+
- `make_handlers!` — generates a `Handlers` trait and `DefaultHandlers` struct as a customizable link between the Lambda runtime and the AppSync operations.
15+
- **`make_appsync!` convenience macro**: combines all three composable macros in a single invocation, recommended for the common single-Lambda-function use case
16+
- **`Handlers` trait**: generated trait with default implementations for `appsync_handler`, `appsync_batch_handler` (when `batch = true`), and `service_fn`. Users can override individual methods to customize handler behavior (authentication hooks, logging, etc.) while keeping defaults for the rest
17+
- **`default_traits` option** on `make_types!` / `make_appsync!`: controls whether the macro applies its default set of derive traits on a given type (`default_traits = MyType: false`)
18+
- **`derive` option** on `make_types!` / `make_appsync!`: adds extra derive macros on top of the defaults for a given type (`derive = MyType: Default`). Supports `Default` on enums (first variant becomes the default value)
19+
- **`type_module` option** on `make_operation!`: specifies the module path to types generated by `make_types!` in a different module or crate, as an alternative to bringing them all into scope
20+
- **`operation_type` option** on `make_handlers!`: specifies a custom path to the `Operation` type when it lives in a different module
21+
- **`error_logging` option** on `make_operation!` / `make_appsync!` (feature: `log`): controls whether the generated `execute` method logs errors via `log::error!` before converting them to an `AppsyncResponse` (default: `true`)
22+
- **`const fn index(self) -> usize`** on every generated enum type, enabling array indexing by enum variant
23+
- **`const fn all()`** on generated enums (changed from non-const to const)
24+
- `data()` and `error()` getters on `AppsyncResponse`
25+
- When the `tracing` feature is enabled, the default batch handler spawns each child task with a dedicated `tracing::info_span!`, linking per-operation spans to the parent invocation
26+
- Re-exports of `lambda_runtime`, `serde`, `serde_json`, and `tokio` as core dependencies (always available, not behind a feature flag)
27+
28+
### Changed
29+
- **Breaking**: The crate no longer generates `main()`, log initialization, or AWS SDK client singletons. Users write their own `main()` and initialize these concerns directly. This is a deliberate design change: generating `main()` and instantiating SDK clients are application-level concerns that don't belong in a type-generation / operation-dispatch crate. The monolithic approach led to unsustainable option proliferation (every new logging framework or instrumentation pattern required another macro option and feature flag) and made it impossible to compose with external middleware such as Tower layers. See [PR #12](https://github.com/RustyServerless/lambda-appsync/pull/12) for the full rationale
30+
- **Breaking**: Default features are now empty. `env_logger` is no longer enabled by default. Add `features = ["env_logger"]` to restore the previous behavior
31+
- **Breaking**: The `hook`, `log_init`, `event_logging`, `only_appsync_types`, `exclude_appsync_types`, `only_appsync_operations`, `exclude_appsync_operations`, `only_lambda_handler`, `exclude_lambda_handler`, and AWS SDK client definition options are no longer available in the default API. They remain available through `appsync_lambda_main!` behind the `compat` feature
32+
- **Breaking**: `#[appsync_operation]` now **preserves the original function** by default (it used to inline the body and remove the function). A new `inline_and_remove` parameter is available when you want the old behavior — the function body is inlined into the generated `impl Operation` method and the original function is removed. The `keep_original_function_name` parameter is moved behind the `compat` feature. Enabling `compat` also restores the old default behavior (inline and remove)
33+
- Repository migrated to the [RustyServerless](https://github.com/RustyServerless) organization
34+
35+
### Deprecated
36+
- **`appsync_lambda_main!` macro**: moved behind the `compat` feature flag. It is refactored internally to delegate to the three composable macros. Prefer `make_appsync!` or the individual macros for new code
37+
38+
### Fixed
39+
- Stopped using the GraphQL schema file path span in generated error diagnostics, which could produce confusing error locations
40+
41+
[0.10.0]: https://github.com/RustyServerless/lambda-appsync/compare/v0.9.0...v0.10.0
42+
843
## [0.9.0] - 2026-01-09
944

1045
### Added

0 commit comments

Comments
 (0)