nest_rs_resource_macros/lib.rs
1//! `#[expose]`, re-exported by `nestrs-resource`.
2//!
3//! An *attribute* (not a derive) so it composes with `#[sea_orm::model]`, which
4//! re-emits the struct and would double-expand a sibling derive.
5
6use proc_macro::TokenStream;
7
8mod active;
9mod attr;
10mod dto;
11mod expose;
12mod input;
13mod relations;
14mod wire;
15
16/// Expose a SeaORM entity to GraphQL + OpenAPI from one declaration. Emits a
17/// GraphQL output object (`SimpleObject` + `JsonSchema`) and `Create/Update`
18/// input types; re-emits the entity untouched so the ORM macros keep full
19/// power.
20///
21/// ```ignore
22/// #[expose(name = "User")]
23/// #[sea_orm::model]
24/// pub struct Model {
25/// #[sea_orm(primary_key, auto_increment = false)]
26/// pub id: Uuid,
27/// #[expose(skip)]
28/// pub org_id: Uuid,
29/// #[expose(input(create, update), validate(length(min = 1)))]
30/// pub name: String,
31/// #[expose(input(create), validate(email))]
32/// pub email: String,
33/// }
34/// ```
35///
36/// Generates `User`, `CreateUserInput`, `UpdateUserInput`, `From<&Model> for
37/// User`. Adding `paginate` also emits `UserPage`.
38#[proc_macro_attribute]
39pub fn expose(args: TokenStream, item: TokenStream) -> TokenStream {
40 expose::expose(args, item)
41}