juniper/juniper_codegen/src/lib.rs

44 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;
#[macro_use]
extern crate quote;
2018-01-13 12:25:55 +01: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 15:22:21 +02:00
mod util;
use proc_macro::TokenStream;
#[proc_macro_derive(GraphQLEnum, attributes(graphql))]
pub fn derive_enum(input: TokenStream) -> TokenStream {
2018-05-03 01:21:08 +02:00
let ast = syn::parse::<syn::DeriveInput>(input).unwrap();
let gen = derive_enum::impl_enum(&ast);
2018-05-03 01:21:08 +02:00
gen.into()
}
2017-06-24 20:20:00 +02:00
#[proc_macro_derive(GraphQLInputObject, attributes(graphql))]
pub fn derive_input_object(input: TokenStream) -> TokenStream {
2018-05-03 01:21:08 +02:00
let ast = syn::parse::<syn::DeriveInput>(input).unwrap();
let gen = derive_input_object::impl_input_object(&ast);
2018-05-03 01:21:08 +02:00
gen.into()
2017-06-24 20:20:00 +02:00
}
#[proc_macro_derive(GraphQLObject, attributes(graphql))]
pub fn derive_object(input: TokenStream) -> TokenStream {
2018-05-03 01:21:08 +02:00
let ast = syn::parse::<syn::DeriveInput>(input).unwrap();
let gen = derive_object::impl_object(&ast);
2018-05-03 01:21:08 +02:00
gen.into()
}