Provide type info to the concrete_type_name

This commit is contained in:
Ivan Dubrov 2018-01-18 16:35:03 -08:00 committed by Magnus Hallin
parent d00e74bb4e
commit bfe2ef511a
5 changed files with 6 additions and 6 deletions
juniper/src
juniper_codegen/src

View file

@ -281,7 +281,7 @@ macro_rules! graphql_interface {
$($items)*); $($items)*);
} }
fn concrete_type_name(&$mainself, context: &Self::Context) -> String { fn concrete_type_name(&$mainself, context: &Self::Context, _info: &()) -> String {
graphql_interface!( graphql_interface!(
@ concrete_type_name, @ concrete_type_name,
($outname, context, $ctxt), ($outname, context, $ctxt),

View file

@ -406,7 +406,7 @@ macro_rules! graphql_object {
mt.into_meta() mt.into_meta()
} }
fn concrete_type_name(&self, _: &Self::Context) -> String { fn concrete_type_name(&self, _: &Self::Context, _: &()) -> String {
$outname.to_owned() $outname.to_owned()
} }

View file

@ -131,7 +131,7 @@ macro_rules! graphql_union {
mt.into_meta() mt.into_meta()
} }
fn concrete_type_name(&$mainself, context: &Self::Context) -> String { fn concrete_type_name(&$mainself, context: &Self::Context, _: &()) -> String {
graphql_union!( graphql_union!(
@ concrete_type_name, @ concrete_type_name,
($outname, context, $ctxt), ($outname, context, $ctxt),

View file

@ -289,7 +289,7 @@ pub trait GraphQLType: Sized {
/// ///
/// The default implementation panics. /// The default implementation panics.
#[allow(unused_variables)] #[allow(unused_variables)]
fn concrete_type_name(&self, context: &Self::Context) -> String { fn concrete_type_name(&self, context: &Self::Context, info: &Self::TypeInfo) -> String {
panic!("concrete_type_name must be implemented by unions and interfaces"); panic!("concrete_type_name must be implemented by unions and interfaces");
} }
@ -357,7 +357,7 @@ where
if f.name.item == "__typename" { if f.name.item == "__typename" {
result.insert( result.insert(
(*response_name).to_owned(), (*response_name).to_owned(),
Value::string(instance.concrete_type_name(executor.context())), Value::string(instance.concrete_type_name(executor.context(), info)),
); );
continue; continue;
} }

View file

@ -150,7 +150,7 @@ pub fn impl_object(ast: &syn::DeriveInput) -> Tokens {
Some(#name) Some(#name)
} }
fn concrete_type_name(&self, _: &Self::Context) -> String { fn concrete_type_name(&self, _: &Self::Context, _: &()) -> String {
#name.to_string() #name.to_string()
} }