juniper/juniper_codegen/src/lib.rs

29 lines
728 B
Rust
Raw Normal View History

#![recursion_limit = "1024"]
extern crate proc_macro;
extern crate syn;
#[macro_use]
extern crate quote;
mod util;
mod enums;
2017-06-24 13:20:00 -05:00
mod input_objects;
use proc_macro::TokenStream;
#[proc_macro_derive(GraphQLEnum, attributes(graphql))]
pub fn derive_enum(input: TokenStream) -> TokenStream {
let s = input.to_string();
let ast = syn::parse_derive_input(&s).unwrap();
let gen = enums::impl_enum(&ast);
gen.parse().unwrap()
}
2017-06-24 13:20:00 -05:00
#[proc_macro_derive(GraphQLInputObject, attributes(graphql))]
pub fn derive_input_object(input: TokenStream) -> TokenStream {
let s = input.to_string();
let ast = syn::parse_derive_input(&s).unwrap();
let gen = input_objects::impl_input_object(&ast);
gen.parse().unwrap()
}