entity_async_graphql_macros/
lib.rs1#![forbid(unsafe_code)]
2
3mod attribute;
4mod data;
5mod derive;
6mod utils;
7
8use syn::{parse_macro_input, AttributeArgs, DeriveInput};
9
10#[proc_macro_derive(EntObject, attributes(ent))]
12pub fn derive_ent_object(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
13 utils::do_derive(derive::do_derive_ent_object)(input)
14}
15
16#[proc_macro_derive(EntFilter, attributes(ent))]
18pub fn derive_ent_filter(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
19 utils::do_derive(derive::do_derive_ent_filter)(input)
20}
21
22#[proc_macro_attribute]
40pub fn gql_ent(
41 args: proc_macro::TokenStream,
42 input: proc_macro::TokenStream,
43) -> proc_macro::TokenStream {
44 let args = parse_macro_input!(args as AttributeArgs);
45 let input = parse_macro_input!(input as DeriveInput);
46
47 let expanded = utils::entity_crate()
48 .and_then(|root| attribute::do_gql_ent(root, args, input))
49 .unwrap_or_else(|x| x.write_errors());
50
51 proc_macro::TokenStream::from(expanded)
52}