juniper/juniper_codegen/src/lib.rs

45 lines
1.2 KiB
Rust
Raw Normal View History

//! This crate supplies custom derive implementations for the
//! [juniper](https://github.com/graphql-rust/juniper) crate.
//!
//! You should not depend on juniper_codegen directly.
//! You only need the `juniper` crate.
#![recursion_limit = "1024"]
extern crate proc_macro;
extern crate proc_macro2;
#[macro_use]
extern crate quote;
2018-01-13 05:25:55 -06:00
extern crate syn;
#[macro_use]
extern crate lazy_static;
extern crate regex;
mod derive_enum;
mod derive_input_object;
mod derive_object;
2018-07-19 08:22:21 -05:00
mod util;
use proc_macro::TokenStream;
#[proc_macro_derive(GraphQLEnum, attributes(graphql))]
pub fn derive_enum(input: TokenStream) -> TokenStream {
2018-05-02 18:21:08 -05:00
let ast = syn::parse::<syn::DeriveInput>(input).unwrap();
let gen = derive_enum::impl_enum(&ast);
2018-05-02 18:21:08 -05:00
gen.into()
}
2017-06-24 13:20:00 -05:00
#[proc_macro_derive(GraphQLInputObject, attributes(graphql))]
pub fn derive_input_object(input: TokenStream) -> TokenStream {
2018-05-02 18:21:08 -05:00
let ast = syn::parse::<syn::DeriveInput>(input).unwrap();
let gen = derive_input_object::impl_input_object(&ast);
2018-05-02 18:21:08 -05:00
gen.into()
2017-06-24 13:20:00 -05:00
}
#[proc_macro_derive(GraphQLObject, attributes(graphql))]
pub fn derive_object(input: TokenStream) -> TokenStream {
2018-05-02 18:21:08 -05:00
let ast = syn::parse::<syn::DeriveInput>(input).unwrap();
let gen = derive_object::impl_object(&ast);
2018-05-02 18:21:08 -05:00
gen.into()
}