Refactor macros to use $crate:: method instead of local_inner_macros.

This commit refactors the macros to use the $crate::inner_macro
trick instead of local_inner_macros.

This is possible since we only support rust 1.30 as a minimum version.
(the $crate:: method only works on 1.30+).

With this change, the wrapper helper macros for std macros can also
be removed.
This commit is contained in:
Christoph Herzog 2018-12-18 23:22:43 +01:00 committed by theduke
parent dee849c88b
commit 3f1ae66b2c
6 changed files with 107 additions and 132 deletions

View file

@ -61,7 +61,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [$($lifetime,)*],
@ -82,7 +82,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [$($lifetime,)*],
@ -102,7 +102,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [$($lifetime,)*],
@ -123,7 +123,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [],
@ -144,7 +144,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [],
@ -165,7 +165,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [],
@ -186,7 +186,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [$($lifetime,)*],
@ -207,7 +207,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [$($lifetime,)*],
@ -227,7 +227,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [$($lifetime,)*],
@ -250,7 +250,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [],
@ -270,7 +270,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [],
@ -290,7 +290,7 @@ macro_rules! __juniper_parse_object_header {
$($items: tt)*
}
) => {
$callback!(
$crate::$callback!(
@parse,
meta = {
lifetimes = [],
@ -311,7 +311,6 @@ macro_rules! __juniper_parse_object_header {
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __juniper_parse_field_list {
@ -322,7 +321,7 @@ macro_rules! __juniper_parse_field_list {
items = [$({$($items: tt)*},)*],
rest =
) => {
$success_callback!(
$crate::$success_callback!(
@generate,
meta = {$($meta)*},
items = [$({$($items)*},)*],
@ -336,7 +335,7 @@ macro_rules! __juniper_parse_field_list {
items = [$({$($items: tt)*},)*],
rest = , $($rest: tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {$($meta)*},
@ -363,7 +362,7 @@ macro_rules! __juniper_parse_field_list {
items = [$({$($items: tt)*},)*],
rest = $desc: tt $($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {
@ -388,7 +387,7 @@ macro_rules! __juniper_parse_field_list {
items = [$({$($items: tt)*},)*],
rest = description: $($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
@parse_description,
success_callback = $success_callback,
additional_parser = {$($additional)*},
@ -411,7 +410,7 @@ macro_rules! __juniper_parse_field_list {
) -> $return_ty: ty $body: block
$($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {$($meta)*},
@ -446,7 +445,7 @@ macro_rules! __juniper_parse_field_list {
) -> $return_ty: ty $body: block
$($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {$($meta)*},
@ -479,7 +478,7 @@ macro_rules! __juniper_parse_field_list {
) -> $return_ty: ty $(as $desc: tt)* $body: block
$($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {$($meta)*},
@ -513,7 +512,7 @@ macro_rules! __juniper_parse_field_list {
) -> $return_ty: ty $(as $desc: tt)* $body: block
$($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {$($meta)*},
@ -546,7 +545,7 @@ macro_rules! __juniper_parse_field_list {
items = [$({$($items: tt)*},)*],
rest = $($rest:tt)*
) => {
$callback!(
$crate::$callback!(
$($header)*
success_callback = $success_callback,
additional_parser = {
@ -586,7 +585,7 @@ macro_rules! __juniper_parse_instance_resolver {
$( $srctype:ty => $resolver:expr ),* $(,)*
} $($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {
@ -633,7 +632,7 @@ macro_rules! __juniper_parse_instance_resolver {
items = [$({$($items: tt)*},)*],
rest = instance_resolvers: |$(&)* _| {$( $srctype:ty => $resolver:expr ),* $(,)*} $($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {

View file

@ -85,7 +85,7 @@ graphql_interface!(<'a> &'a Character: Database as "Character" |&self| {
[1]: macro.graphql_object!.html
*/
#[macro_export(local_inner_macros)]
#[macro_export]
macro_rules! graphql_interface {
(
@ -127,7 +127,7 @@ macro_rules! graphql_interface {
$(executor_var = $executor: ident,)*
},)*],
) => {
__juniper_impl_trait!(
$crate::__juniper_impl_trait!(
impl<$($scalar)* $(, $lifetimes)* > GraphQLType for $name {
type Context = $ctx;
type TypeInfo = ();
@ -138,10 +138,10 @@ macro_rules! graphql_interface {
fn meta<'r>(
info: &Self::TypeInfo,
registry: &mut $crate::Registry<'r, __juniper_insert_generic!($($scalar)+)>
) -> $crate::meta::MetaType<'r, __juniper_insert_generic!($($scalar)+)>
where for<'__b> &'__b __juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
__juniper_insert_generic!($($scalar)+): 'r
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
$crate::__juniper_insert_generic!($($scalar)+): 'r
{
// Ensure all child types are registered
$(
@ -149,14 +149,14 @@ macro_rules! graphql_interface {
)*
let fields = &[$(
registry.field_convert::<$return_ty, _, Self::Context>(
&$crate::to_camel_case(__graphql__stringify!($fn_name)),
&$crate::to_camel_case(stringify!($fn_name)),
info
)
$(.description($fn_description))*
.push_docstring(&[$($docstring,)*])
$(.deprecated($deprecated))*
$(.argument(
__juniper_create_arg!(
$crate::__juniper_create_arg!(
registry = registry,
info = info,
arg_ty = $arg_ty,
@ -180,17 +180,17 @@ macro_rules! graphql_interface {
&$main_self,
info: &Self::TypeInfo,
field: &str,
args: &$crate::Arguments<__juniper_insert_generic!($($scalar)+)>,
executor: &$crate::Executor<Self::Context, __juniper_insert_generic!($($scalar)+)>
) -> $crate::ExecutionResult<__juniper_insert_generic!($($scalar)+)> {
args: &$crate::Arguments<$crate::__juniper_insert_generic!($($scalar)+)>,
executor: &$crate::Executor<Self::Context, $crate::__juniper_insert_generic!($($scalar)+)>
) -> $crate::ExecutionResult<$crate::__juniper_insert_generic!($($scalar)+)> {
$(
if field == &$crate::to_camel_case(__graphql__stringify!($fn_name)) {
if field == &$crate::to_camel_case(stringify!($fn_name)) {
let result: $return_ty = (|| {
$(
let $arg_name: $arg_ty = args.get(&$crate::to_camel_case(stringify!($arg_name)))
.expect(__graphql__concat!(
.expect(concat!(
"Argument ",
__graphql__stringify!($arg_name),
stringify!($arg_name),
" missing - validation must have failed"
));
)*
@ -213,7 +213,7 @@ macro_rules! graphql_interface {
}
)*
__graphql__panic!("Field {} not found on type {}", field, $($outname)*)
panic!("Field {} not found on type {}", field, $($outname)*)
}
#[allow(unused_variables)]
@ -227,16 +227,16 @@ macro_rules! graphql_interface {
}
)*
__graphql__panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
}
fn resolve_into_type(
&$main_self,
_info: &Self::TypeInfo,
type_name: &str,
_: Option<&[$crate::Selection<__juniper_insert_generic!($($scalar)*)>]>,
executor: &$crate::Executor<Self::Context, __juniper_insert_generic!($($scalar)*)>,
) -> $crate::ExecutionResult<__juniper_insert_generic!($($scalar)*)> {
_: Option<&[$crate::Selection<$crate::__juniper_insert_generic!($($scalar)*)>]>,
executor: &$crate::Executor<Self::Context, $crate::__juniper_insert_generic!($($scalar)*)>,
) -> $crate::ExecutionResult<$crate::__juniper_insert_generic!($($scalar)*)> {
$(let $resolver_ctx = &executor.context();)*
$(
@ -245,7 +245,7 @@ macro_rules! graphql_interface {
}
)*
__graphql__panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
}
}
);
@ -256,7 +256,7 @@ macro_rules! graphql_interface {
meta = {$($meta:tt)*},
rest = $($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = graphql_interface,
additional_parser = {
callback = __juniper_parse_instance_resolver,
@ -269,13 +269,13 @@ macro_rules! graphql_interface {
};
(@$($stuff:tt)*) => {
__graphql__compile_error!("Invalid syntax for `graphql_interface!`");
compile_error!("Invalid syntax for `graphql_interface!`");
};
(
$($rest:tt)*
) => {
__juniper_parse_object_header!(
$crate::__juniper_parse_object_header!(
callback = graphql_interface,
rest = $($rest)*
);

View file

@ -1,29 +1,5 @@
// Wrapper macros which allows built-in macros to be recognized as "crate-local".
#[doc(hidden)]
#[macro_export]
macro_rules! __graphql__panic {
($($t:tt)*) => ( panic!($($t)*) );
}
#[doc(hidden)]
#[macro_export]
macro_rules! __graphql__stringify {
($($t:tt)*) => ( stringify!($($t)*) );
}
#[doc(hidden)]
#[macro_export]
macro_rules! __graphql__concat {
($($t:tt)*) => ( concat!($($t)*) );
}
#[doc(hidden)]
#[macro_export]
macro_rules! __graphql__compile_error {
($t:expr) => ( compile_error!($t) );
}
#[macro_use]
mod common;
#[macro_use]

View file

@ -310,7 +310,7 @@ arg_name: ArgType
[1]: struct.Executor.html
*/
#[macro_export(local_inner_macros)]
#[macro_export]
macro_rules! graphql_object {
(
@generate,
@ -343,7 +343,7 @@ macro_rules! graphql_object {
$(executor_var = $executor: ident,)*
},)*],
) => {
__juniper_impl_trait!(
$crate::__juniper_impl_trait!(
impl<$($scalar)* $(, $lifetimes)* > GraphQLType for $name {
type Context = $ctx;
type TypeInfo = ();
@ -354,21 +354,21 @@ macro_rules! graphql_object {
fn meta<'r>(
info: &Self::TypeInfo,
registry: &mut $crate::Registry<'r, __juniper_insert_generic!($($scalar)+)>
) -> $crate::meta::MetaType<'r, __juniper_insert_generic!($($scalar)+)>
where for<'__b> &'__b __juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
__juniper_insert_generic!($($scalar)+): 'r
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
$crate::__juniper_insert_generic!($($scalar)+): 'r
{
let fields = &[$(
registry.field_convert::<$return_ty, _, Self::Context>(
&$crate::to_camel_case(__graphql__stringify!($fn_name)),
&$crate::to_camel_case(stringify!($fn_name)),
info
)
$(.description($fn_description))*
.push_docstring(&[$($docstring,)*])
$(.deprecated($deprecated))*
$(.argument(
__juniper_create_arg!(
$crate::__juniper_create_arg!(
registry = registry,
info = info,
arg_ty = $arg_ty,
@ -398,17 +398,17 @@ macro_rules! graphql_object {
&$main_self,
info: &Self::TypeInfo,
field: &str,
args: &$crate::Arguments<__juniper_insert_generic!($($scalar)+)>,
executor: &$crate::Executor<Self::Context, __juniper_insert_generic!($($scalar)+)>
) -> $crate::ExecutionResult<__juniper_insert_generic!($($scalar)+)> {
args: &$crate::Arguments<$crate::__juniper_insert_generic!($($scalar)+)>,
executor: &$crate::Executor<Self::Context, $crate::__juniper_insert_generic!($($scalar)+)>
) -> $crate::ExecutionResult<$crate::__juniper_insert_generic!($($scalar)+)> {
$(
if field == &$crate::to_camel_case(__graphql__stringify!($fn_name)) {
if field == &$crate::to_camel_case(stringify!($fn_name)) {
let result: $return_ty = (|| {
$(
let $arg_name: $arg_ty = args.get(&$crate::to_camel_case(__graphql__stringify!($arg_name)))
.expect(__graphql__concat!(
let $arg_name: $arg_ty = args.get(&$crate::to_camel_case(stringify!($arg_name)))
.expect(concat!(
"Argument ",
__graphql__stringify!($arg_name),
stringify!($arg_name),
" missing - validation must have failed"
));
)*
@ -431,7 +431,7 @@ macro_rules! graphql_object {
}
)*
__graphql__panic!("Field {} not found on type {}", field, $($outname)*);
panic!("Field {} not found on type {}", field, $($outname)*);
}
}
);
@ -457,7 +457,7 @@ macro_rules! graphql_object {
items = [$({$($items: tt)*},)*],
rest = [$($interface: ty),+] $($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = $success_callback,
additional_parser = {$($additional)*},
meta = {
@ -485,7 +485,7 @@ macro_rules! graphql_object {
items = [$({$($items: tt)*},)*],
rest = interfaces: $($rest:tt)*
) => {
graphql_object!(
$crate::graphql_object!(
@parse_interfaces,
success_callback = $success_callback,
additional_parser = {$($additional)*},
@ -501,7 +501,7 @@ macro_rules! graphql_object {
meta = {$($meta:tt)*},
rest = $($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = graphql_object,
additional_parser = {
callback = graphql_object,
@ -514,13 +514,13 @@ macro_rules! graphql_object {
};
(@$($stuff:tt)*) => {
__graphql__compile_error!("Invalid syntax for `graphql_object!`");
compile_error!("Invalid syntax for `graphql_object!`");
};
(
$($rest:tt)*
) => {
__juniper_parse_object_header!(
$crate::__juniper_parse_object_header!(
callback = graphql_object,
rest = $($rest)*
);

View file

@ -45,7 +45,7 @@ In addition to implementing `GraphQLType` for the type in question,
usable as arguments and default values.
*/
#[macro_export(local_inner_macros)]
#[macro_export]
macro_rules! graphql_scalar {
( @as_expr $e:expr) => { $e };
(
@ -74,21 +74,21 @@ macro_rules! graphql_scalar {
},
) => {
__juniper_impl_trait!(
$crate::__juniper_impl_trait!(
impl <$($scalar)+> GraphQLType for $name {
type Context = ();
type TypeInfo = ();
fn name(_: &Self::TypeInfo) -> Option<&str> {
Some(graphql_scalar!(@as_expr $($outname)+))
Some($crate::graphql_scalar!(@as_expr $($outname)+))
}
fn meta<'r>(
info: &Self::TypeInfo,
registry: &mut $crate::Registry<'r, __juniper_insert_generic!($($scalar)+)>
) -> $crate::meta::MetaType<'r, __juniper_insert_generic!($($scalar)+)>
where for<'__b> &'__b __juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
__juniper_insert_generic!($($scalar)+): 'r
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
$crate::__juniper_insert_generic!($($scalar)+): 'r
{
let meta = registry.build_scalar_type::<Self>(info);
$(
@ -100,35 +100,35 @@ macro_rules! graphql_scalar {
fn resolve(
&$resolve_self_var,
_: &(),
_: Option<&[$crate::Selection<__juniper_insert_generic!($($scalar)+)>]>,
_: Option<&[$crate::Selection<$crate::__juniper_insert_generic!($($scalar)+)>]>,
_: &$crate::Executor<
Self::Context,
__juniper_insert_generic!($($scalar)+)
>) -> $crate::Value<__juniper_insert_generic!($($scalar)+)> {
$crate::__juniper_insert_generic!($($scalar)+)
>) -> $crate::Value<$crate::__juniper_insert_generic!($($scalar)+)> {
$resolve_body
}
});
__juniper_impl_trait!(
$crate::__juniper_impl_trait!(
impl<$($scalar)+> ToInputValue for $name {
fn to_input_value(&$resolve_self_var) -> $crate::InputValue<__juniper_insert_generic!($($scalar)+)> {
fn to_input_value(&$resolve_self_var) -> $crate::InputValue<$crate::__juniper_insert_generic!($($scalar)+)> {
let v = $resolve_body;
$crate::ToInputValue::to_input_value(&v)
}
}
);
__juniper_impl_trait!(
$crate::__juniper_impl_trait!(
impl<$($scalar)+> FromInputValue for $name {
fn from_input_value(
$from_input_value_arg: &$crate::InputValue<__juniper_insert_generic!($($scalar)+)>
$from_input_value_arg: &$crate::InputValue<$crate::__juniper_insert_generic!($($scalar)+)>
) -> $from_input_value_result {
$from_input_value_body
}
}
);
__juniper_impl_trait!(
$crate::__juniper_impl_trait!(
impl<$($scalar)+> ParseScalarValue for $name {
fn from_str<$from_str_lt>($from_str_arg: $crate::parser::ScalarToken<$from_str_lt>) -> $from_str_result {
$from_str_body
@ -151,7 +151,7 @@ macro_rules! graphql_scalar {
from_str = {$($from_str_body:tt)+},
rest =
) => {
graphql_scalar!(
$crate::graphql_scalar!(
@generate,
meta = {
name = $name,
@ -177,7 +177,7 @@ macro_rules! graphql_scalar {
$(from_str = {$($from_str_body:tt)+})*,
rest =
) => {
__graphql__compile_error!("Missing resolve function");
compile_error!("Missing resolve function");
};
(
@ -192,7 +192,7 @@ macro_rules! graphql_scalar {
$(from_str = {$($from_str_body:tt)+})*,
rest =
) => {
__graphql__compile_error!("Missing from_input_value function");
compile_error!("Missing from_input_value function");
};
(
@ -207,7 +207,7 @@ macro_rules! graphql_scalar {
from_input_value = {$($from_input_value_body:tt)+},
rest =
) =>{
__graphql__compile_error!("Missing from_str function");
compile_error!("Missing from_str function");
};
@ -220,7 +220,7 @@ macro_rules! graphql_scalar {
$(from_str = {$($from_str_body:tt)+},)*
rest = resolve(&$selfvar:ident) -> $return_ty:ty $body:block $($rest:tt)*
) => {
graphql_scalar!(
$crate::graphql_scalar!(
@parse_functions,
meta = {$($meta)*},
resolve = {
@ -243,7 +243,7 @@ macro_rules! graphql_scalar {
$(from_str = {$($from_str_body:tt)+},)*
rest = from_input_value($arg:ident: &InputValue) -> $result:ty $body:block $($rest:tt)*
) => {
graphql_scalar!(
$crate::graphql_scalar!(
@parse_functions,
meta = { $($meta)* },
$(resolve = {$($resolve_body)+},)*
@ -266,7 +266,7 @@ macro_rules! graphql_scalar {
$(from_str = {$($from_str_body:tt)+},)*
rest = from_str<$from_str_lt: tt>($value_arg:ident: ScalarToken<$ignored_lt2: tt>) -> $result:ty $body:block $($rest:tt)*
) => {
graphql_scalar!(
$crate::graphql_scalar!(
@parse_functions,
meta = { $($meta)* },
$(resolve = {$($resolve_body)+},)*
@ -294,7 +294,7 @@ macro_rules! graphql_scalar {
$(from_str = {$($from_str_body:tt)+},)*
rest = description: $descr:tt $($rest:tt)*
) => {
graphql_scalar!(
$crate::graphql_scalar!(
@parse_functions,
meta = {
name = $name,
@ -319,7 +319,7 @@ macro_rules! graphql_scalar {
},
rest = $($rest:tt)*
) => {
graphql_scalar!(
$crate::graphql_scalar!(
@parse_functions,
meta = {
name = $name,
@ -331,11 +331,11 @@ macro_rules! graphql_scalar {
};
(@$($stuff:tt)*) => {
__graphql__compile_error!("Invalid syntax for `graphql_scalar!`");
compile_error!("Invalid syntax for `graphql_scalar!`");
};
($($rest:tt)*) => {
__juniper_parse_object_header!(
$crate::__juniper_parse_object_header!(
callback = graphql_scalar,
rest = $($rest)*
);

View file

@ -17,7 +17,7 @@ resolvers.
[1]: macro.graphql_object!.html
[2]: macro.graphql_interface!.html
*/
#[macro_export(local_inner_macros)]
#[macro_export]
macro_rules! graphql_union {
(
@ -44,7 +44,7 @@ macro_rules! graphql_union {
},
items = [],
) => {
__juniper_impl_trait!(
$crate::__juniper_impl_trait!(
impl<$($scalar)* $(, $lifetimes)* > GraphQLType for $name {
type Context = $ctx;
type TypeInfo = ();
@ -55,10 +55,10 @@ macro_rules! graphql_union {
fn meta<'r>(
info: &Self::TypeInfo,
registry: &mut $crate::Registry<'r, __juniper_insert_generic!($($scalar)+)>
) -> $crate::meta::MetaType<'r, __juniper_insert_generic!($($scalar)+)>
where for<'__b> &'__b __juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
__juniper_insert_generic!($($scalar)+): 'r
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
$crate::__juniper_insert_generic!($($scalar)+): 'r
{
let types = &[
$(
@ -83,16 +83,16 @@ macro_rules! graphql_union {
}
)*
__graphql__panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
}
fn resolve_into_type(
&$main_self,
_info: &Self::TypeInfo,
type_name: &str,
_: Option<&[$crate::Selection<__juniper_insert_generic!($($scalar)*)>]>,
executor: &$crate::Executor<Self::Context, __juniper_insert_generic!($($scalar)*)>,
) -> $crate::ExecutionResult<__juniper_insert_generic!($($scalar)*)> {
_: Option<&[$crate::Selection<$crate::__juniper_insert_generic!($($scalar)*)>]>,
executor: &$crate::Executor<Self::Context, $crate::__juniper_insert_generic!($($scalar)*)>,
) -> $crate::ExecutionResult<$crate::__juniper_insert_generic!($($scalar)*)> {
$(let $resolver_ctx = &executor.context();)*
$(
@ -101,7 +101,7 @@ macro_rules! graphql_union {
}
)*
__graphql__panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
}
}
);
@ -113,7 +113,7 @@ macro_rules! graphql_union {
meta = {$($meta:tt)*},
rest = $($rest:tt)*
) => {
__juniper_parse_field_list!(
$crate::__juniper_parse_field_list!(
success_callback = graphql_union,
additional_parser = {
callback = __juniper_parse_instance_resolver,
@ -125,11 +125,11 @@ macro_rules! graphql_union {
);
};
(@$($stuff:tt)*) => {
__graphql__compile_error!("Invalid syntax for `graphql_union!`");
compile_error!("Invalid syntax for `graphql_union!`");
};
($($rest: tt)*) => {
__juniper_parse_object_header!(
$crate::__juniper_parse_object_header!(
callback = graphql_union,
rest = $($rest)*
);