diff --git a/juniper_codegen/src/impl_object.rs b/juniper_codegen/src/impl_object.rs index dd984794..db7ad2e1 100644 --- a/juniper_codegen/src/impl_object.rs +++ b/juniper_codegen/src/impl_object.rs @@ -41,11 +41,18 @@ pub fn build_object(args: TokenStream, body: TokenStream, is_internal: bool) -> } } - let name = if let Some(ident) = util::name_of_type(&*_impl.self_ty) { - ident - } else { - panic!("Could not determine a name for the object type: specify one with #[juniper::object(name = \"SomeName\")"); - }; + + let name = + if let Some(name) = impl_attrs.name.as_ref(){ + name.to_string() + } + else { + if let Some(ident) = util::name_of_type(&*_impl.self_ty) { + ident.to_string() + } else { + panic!("Could not determine a name for the object type: specify one with #[juniper::object(name = \"SomeName\")"); + } + }; let target_type = *_impl.self_ty.clone(); @@ -54,7 +61,7 @@ pub fn build_object(args: TokenStream, body: TokenStream, is_internal: bool) -> .or(util::get_doc_comment(&_impl.attrs)); let mut definition = util::GraphQLTypeDefiniton { - name: name.to_string(), + name: name, _type: target_type.clone(), context: impl_attrs.context, scalar: impl_attrs.scalar,