Skip to main content

lambda_appsync_proc/
lib.rs

1//! Procedural macros for the [`lambda-appsync`](https://docs.rs/lambda-appsync) type-safe AWS
2//! AppSync resolver framework.
3//!
4//! **This crate is not intended for direct use.** Depend on [`lambda-appsync`](https://docs.rs/lambda-appsync)
5//! instead — it re-exports all macros from this crate under a stable, unified API.
6//!
7//! # Provided Macros
8//!
9//! | Macro | Kind | Purpose |
10//! |---|---|---|
11//! | [`make_appsync!`] | function-like | Generate the full AppSync resolver scaffolding from a GraphQL schema |
12//! | [`make_handlers!`] | function-like | Generate handler dispatch glue for a set of operations |
13//! | [`make_operation!`] | function-like | Generate a single typed operation from a GraphQL field definition |
14//! | [`make_types!`] | function-like | Generate Rust types from GraphQL type definitions |
15//! | [`macro@appsync_operation`] | attribute | Annotate an async handler function as an AppSync operation resolver |
16//! | [`appsync_lambda_main!`] | function-like | *(feature: `compat`)* Generate a `main` entry point compatible with the legacy single-resolver pattern |
17//!
18//! Each macro has detailed documentation on its own page, including syntax, options, and examples.
19//!
20//! # Feature Flags
21//!
22//! - **`compat`** — Enables [`appsync_lambda_main!`] for backwards-compatible single-resolver Lambda entry points
23//! - **`log`** — Enables `log`-based logging support in generated code
24//! - **`env_logger`** — Enables `env_logger` initialisation in generated entry points
25//! - **`tracing`** — Enables `tracing`-based instrumentation in generated code
26
27mod internal;
28
29use proc_macro::TokenStream;
30
31#[doc = include_str!("../doc/make_appsync.md")]
32#[proc_macro]
33pub fn make_appsync(input: TokenStream) -> TokenStream {
34    internal::make_appsync::make_appsync_impl(input)
35}
36
37#[doc = include_str!("../doc/make_handlers.md")]
38#[proc_macro]
39pub fn make_handlers(input: TokenStream) -> TokenStream {
40    internal::make_appsync::make_handlers_impl(input)
41}
42
43#[doc = include_str!("../doc/make_operation.md")]
44#[proc_macro]
45pub fn make_operation(input: TokenStream) -> TokenStream {
46    internal::make_appsync::make_operation_impl(input)
47}
48
49#[doc = include_str!("../doc/make_types.md")]
50#[proc_macro]
51pub fn make_types(input: TokenStream) -> TokenStream {
52    internal::make_appsync::make_types_impl(input)
53}
54
55#[doc = include_str!("../doc/appsync_operation.md")]
56#[proc_macro_attribute]
57pub fn appsync_operation(args: TokenStream, input: TokenStream) -> TokenStream {
58    internal::appsync_operation::appsync_operation_impl(args, input)
59}
60
61#[cfg(feature = "compat")]
62#[cfg_attr(feature = "compat", doc = include_str!("../doc/appsync_lambda_main.md"))]
63#[proc_macro]
64pub fn appsync_lambda_main(input: TokenStream) -> TokenStream {
65    internal::make_appsync::legacy::appsync_lambda_main::appsync_lambda_main_impl(input)
66}