diff --git a/juniper/Cargo.toml b/juniper/Cargo.toml index 7fd863413..fa63cf560 100644 --- a/juniper/Cargo.toml +++ b/juniper/Cargo.toml @@ -37,6 +37,7 @@ fnv = "1.0.3" indexmap = { version = "1.0.0", features = ["serde-1"] } serde = { version = "1.0.8" } serde_derive = { version = "1.0.2" } +log = { version = "0.4" } chrono = { version = "0.4.0", optional = true } serde_json = { version="1.0.2", optional = true } diff --git a/juniper/src/lib.rs b/juniper/src/lib.rs index 9cf33a65d..887656f9e 100644 --- a/juniper/src/lib.rs +++ b/juniper/src/lib.rs @@ -118,6 +118,7 @@ pub use juniper_codegen::{ use juniper_codegen::{ object_internal, GraphQLEnumInternal, GraphQLInputObjectInternal, GraphQLScalarValueInternal, }; +use log::{debug, warn}; #[macro_use] mod value; @@ -203,7 +204,9 @@ where let errors = validate_input_values(variables, &document, &root_node.schema); if !errors.is_empty() { - return Err(GraphQLError::ValidationError(errors)); + let err = GraphQLError::ValidationError(errors); + warn!("{:#?}", &err); + return Err(err); } } @@ -213,11 +216,21 @@ where let errors = ctx.into_errors(); if !errors.is_empty() { - return Err(GraphQLError::ValidationError(errors)); + let err = GraphQLError::ValidationError(errors); + warn!("{:#?}", &err); + return Err(err); } } - execute_validated_query(document, operation_name, root_node, variables, context) + let (response, errors) = + execute_validated_query(document, operation_name, root_node, variables, context)?; + + debug!("resolved response to: {:#?}", &response); + if !errors.is_empty() { + warn!("{:#?}", &errors); + } + + Ok((response, errors)) } /// Execute the reference introspection query in the provided schema