2017-12-01 19:35:08 -06:00
|
|
|
//! 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.
|
|
|
|
|
2017-06-24 06:23:20 -05:00
|
|
|
#![recursion_limit = "1024"]
|
|
|
|
|
|
|
|
extern crate proc_macro;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate quote;
|
2018-01-13 05:25:55 -06:00
|
|
|
extern crate syn;
|
2018-05-23 02:25:20 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
extern crate regex;
|
2017-06-24 06:23:20 -05:00
|
|
|
|
|
|
|
mod util;
|
2017-08-02 20:55:33 -05:00
|
|
|
mod derive_enum;
|
|
|
|
mod derive_input_object;
|
2017-08-02 20:49:19 -05:00
|
|
|
mod derive_object;
|
2017-06-24 06:23:20 -05:00
|
|
|
|
|
|
|
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();
|
2017-08-02 20:55:33 -05:00
|
|
|
let gen = derive_enum::impl_enum(&ast);
|
2018-05-02 18:21:08 -05:00
|
|
|
gen.into()
|
2017-06-24 06:23:20 -05:00
|
|
|
}
|
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();
|
2017-08-02 20:55:33 -05:00
|
|
|
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
|
|
|
}
|
2017-08-02 20:49:19 -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();
|
2017-08-02 20:49:19 -05:00
|
|
|
let gen = derive_object::impl_object(&ast);
|
2018-05-02 18:21:08 -05:00
|
|
|
gen.into()
|
2017-08-02 20:49:19 -05:00
|
|
|
}
|