diff --git a/integration_tests/async_await/src/main.rs b/integration_tests/async_await/src/main.rs index c29a3164..46229e3f 100644 --- a/integration_tests/async_await/src/main.rs +++ b/integration_tests/async_await/src/main.rs @@ -1,3 +1,4 @@ +#[cfg(test)] use juniper::{graphql_value, GraphQLError, RootNode, Value}; #[derive(juniper::GraphQLEnum)] @@ -8,13 +9,17 @@ enum UserKind { } struct User { - id: u64, + id: i32, name: String, kind: UserKind, } #[juniper::graphql_object] impl User { + async fn id(&self) -> i32 { + self.id + } + async fn name(&self) -> &str { &self.name } diff --git a/integration_tests/juniper_tests/src/codegen/derive_object.rs b/integration_tests/juniper_tests/src/codegen/derive_object.rs index edf1aaf9..cbeaac7f 100644 --- a/integration_tests/juniper_tests/src/codegen/derive_object.rs +++ b/integration_tests/juniper_tests/src/codegen/derive_object.rs @@ -125,8 +125,8 @@ impl Query { } } -#[test] -fn test_doc_comment_simple() { +#[tokio::test] +async fn test_doc_comment_simple() { let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default()); let meta = DocComment::meta(&(), &mut registry); assert_eq!(meta.description(), Some(&"Object comment.".to_string())); @@ -136,11 +136,12 @@ fn test_doc_comment_simple() { &Value::scalar("Object comment."), "regularField", &Value::scalar("Field comment."), - ); + ) + .await; } -#[test] -fn test_multi_doc_comment() { +#[tokio::test] +async fn test_multi_doc_comment() { let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default()); let meta = MultiDocComment::meta(&(), &mut registry); assert_eq!( @@ -153,11 +154,12 @@ fn test_multi_doc_comment() { &Value::scalar("Doc 1. Doc 2.\n\nDoc 4."), "regularField", &Value::scalar("Field 1.\nField 2."), - ); + ) + .await; } -#[test] -fn test_doc_comment_override() { +#[tokio::test] +async fn test_doc_comment_override() { let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default()); let meta = OverrideDocComment::meta(&(), &mut registry); assert_eq!(meta.description(), Some(&"obj override".to_string())); @@ -167,7 +169,8 @@ fn test_doc_comment_override() { &Value::scalar("obj override"), "regularField", &Value::scalar("field override"), - ); + ) + .await; } #[tokio::test] @@ -291,7 +294,7 @@ async fn test_derived_object_nested() { } #[cfg(test)] -fn check_descriptions( +async fn check_descriptions( object_name: &str, object_description: &Value, field_name: &str, @@ -329,7 +332,8 @@ fn check_descriptions( .into_iter() .collect(), ))); - }); + }) + .await; } #[cfg(test)] diff --git a/integration_tests/juniper_tests/src/codegen/derive_object_with_raw_idents.rs b/integration_tests/juniper_tests/src/codegen/derive_object_with_raw_idents.rs index 5130bc6f..45d79630 100644 --- a/integration_tests/juniper_tests/src/codegen/derive_object_with_raw_idents.rs +++ b/integration_tests/juniper_tests/src/codegen/derive_object_with_raw_idents.rs @@ -1,12 +1,6 @@ -#[cfg(test)] -use fnv::FnvHashMap; -#[cfg(test)] -use juniper::Object; - #[cfg(test)] use juniper::{ - self, execute, graphql_value, DefaultScalarValue, EmptyMutation, GraphQLInputObject, - GraphQLType, RootNode, Value, Variables, + self, execute, graphql_value, EmptyMutation, GraphQLInputObject, RootNode, Value, Variables, }; use futures; diff --git a/integration_tests/juniper_tests/src/issue_371.rs b/integration_tests/juniper_tests/src/issue_371.rs index b29296b3..e2bcdf06 100644 --- a/integration_tests/juniper_tests/src/issue_371.rs +++ b/integration_tests/juniper_tests/src/issue_371.rs @@ -14,13 +14,13 @@ pub struct Query; )] impl Query { fn users(exec: &Executor) -> Vec { - let lh = executor.look_ahead(); + let lh = exec.look_ahead(); assert_eq!(lh.field_name(), "users"); vec![User] } fn countries(exec: &Executor) -> Vec { - let lh = executor.look_ahead(); + let lh = exec.look_ahead(); assert_eq!(lh.field_name(), "countries"); vec![Country] } diff --git a/juniper/src/executor/mod.rs b/juniper/src/executor/mod.rs index ce7c831d..5b3d29fb 100644 --- a/juniper/src/executor/mod.rs +++ b/juniper/src/executor/mod.rs @@ -2,7 +2,7 @@ use std::{ borrow::Cow, cmp::Ordering, collections::HashMap, - fmt::{self, Debug, Display}, + fmt::{Debug, Display}, sync::RwLock, }; diff --git a/juniper/src/executor_tests/async_await/mod.rs b/juniper/src/executor_tests/async_await/mod.rs index ffaf0ae7..28d5fb73 100644 --- a/juniper/src/executor_tests/async_await/mod.rs +++ b/juniper/src/executor_tests/async_await/mod.rs @@ -8,13 +8,17 @@ enum UserKind { } struct User { - id: u64, + id: i32, name: String, kind: UserKind, } #[crate::graphql_object_internal] impl User { + async fn id(&self) -> i32 { + self.id + } + async fn name(&self) -> &str { &self.name } diff --git a/juniper/src/executor_tests/executor.rs b/juniper/src/executor_tests/executor.rs index 111eee19..0b14f1ba 100644 --- a/juniper/src/executor_tests/executor.rs +++ b/juniper/src/executor_tests/executor.rs @@ -464,7 +464,7 @@ mod dynamic_context_switching { #[crate::graphql_object_internal(Context = OuterContext)] impl Schema { - fn item_opt(context: &OuterContext, key: i32) -> Option<(&InnerContext, ItemRef)> { + fn item_opt(_context: &OuterContext, key: i32) -> Option<(&InnerContext, ItemRef)> { executor.context().items.get(&key).map(|c| (c, ItemRef)) } @@ -1085,6 +1085,7 @@ mod named_operations { #[crate::graphql_object_internal] impl Schema { fn a(p: Option) -> &str { + dbg!(p); "b" } } diff --git a/juniper/src/http/mod.rs b/juniper/src/http/mod.rs index 03ddda2a..1209780e 100644 --- a/juniper/src/http/mod.rs +++ b/juniper/src/http/mod.rs @@ -93,6 +93,10 @@ where )) } + /// Execute a GraphQL request using the specified schema and context + /// + /// This is a simple wrapper around the `execute` function exposed at the + /// top level of this crate. pub async fn execute<'a, CtxT, QueryT, MutationT>( &'a self, root_node: &'a RootNode<'a, QueryT, MutationT, S>, diff --git a/juniper/src/macros/tests/args.rs b/juniper/src/macros/tests/args.rs index 6a355376..f7292355 100644 --- a/juniper/src/macros/tests/args.rs +++ b/juniper/src/macros/tests/args.rs @@ -23,7 +23,7 @@ Syntax to validate: */ -#[derive(GraphQLInputObject)] +#[derive(GraphQLInputObject, Debug)] struct Point { x: i32, } @@ -33,28 +33,28 @@ impl Root { fn simple() -> i32 { 0 } - fn exec_arg(executor: &Executor) -> i32 { + fn exec_arg(_executor: &Executor) -> i32 { 0 } - fn exec_arg_and_more(executor: &Executor, arg: i32) -> i32 { - 0 + fn exec_arg_and_more(_executor: &Executor, arg: i32) -> i32 { + arg } fn single_arg(arg: i32) -> i32 { - 0 + arg } fn multi_args(arg1: i32, arg2: i32) -> i32 { - 0 + arg1 + arg2 } fn multi_args_trailing_comma(arg1: i32, arg2: i32) -> i32 { - 0 + arg1 + arg2 } #[graphql(arguments(arg(description = "The arg")))] fn single_arg_descr(arg: i32) -> i32 { - 0 + arg } #[graphql(arguments( @@ -62,7 +62,7 @@ impl Root { arg2(description = "The second arg") ))] fn multi_args_descr(arg1: i32, arg2: i32) -> i32 { - 0 + arg1 + arg2 } #[graphql(arguments( @@ -70,7 +70,7 @@ impl Root { arg2(description = "The second arg") ))] fn multi_args_descr_trailing_comma(arg1: i32, arg2: i32) -> i32 { - 0 + arg1 + arg2 } // TODO: enable once [parameter attributes are supported by proc macros] @@ -87,22 +87,22 @@ impl Root { #[graphql(arguments(arg(default = 123,),))] fn arg_with_default(arg: i32) -> i32 { - 0 + arg } #[graphql(arguments(arg1(default = 123,), arg2(default = 456,)))] fn multi_args_with_default(arg1: i32, arg2: i32) -> i32 { - 0 + arg1 + arg2 } #[graphql(arguments(arg1(default = 123,), arg2(default = 456,),))] fn multi_args_with_default_trailing_comma(arg1: i32, arg2: i32) -> i32 { - 0 + arg1 + arg2 } #[graphql(arguments(arg(default = 123, description = "The arg")))] fn arg_with_default_descr(arg: i32) -> i32 { - 0 + arg } #[graphql(arguments( @@ -110,7 +110,7 @@ impl Root { arg2(default = 456, description = "The second arg") ))] fn multi_args_with_default_descr(arg1: i32, arg2: i32) -> i32 { - 0 + arg1 + arg2 } #[graphql(arguments( @@ -118,7 +118,7 @@ impl Root { arg2(default = 456, description = "The second arg",) ))] fn multi_args_with_default_trailing_comma_descr(arg1: i32, arg2: i32) -> i32 { - 0 + arg1 + arg2 } #[graphql( @@ -134,6 +134,8 @@ impl Root { ), )] fn args_with_complex_default(arg1: String, arg2: Point) -> i32 { + dbg!(arg1); + dbg!(arg2); 0 } } diff --git a/juniper/src/types/containers.rs b/juniper/src/types/containers.rs index 50cecac8..399163d2 100644 --- a/juniper/src/types/containers.rs +++ b/juniper/src/types/containers.rs @@ -256,7 +256,7 @@ where fn resolve_async<'a>( &'a self, info: &'a Self::TypeInfo, - selection_set: Option<&'a [Selection]>, + _selection_set: Option<&'a [Selection]>, executor: &'a Executor, ) -> crate::BoxFuture<'a, ExecutionResult> { let f = resolve_into_list_async(executor, info, self.iter()); @@ -274,7 +274,7 @@ where fn resolve_async<'a>( &'a self, info: &'a Self::TypeInfo, - selection_set: Option<&'a [Selection]>, + _selection_set: Option<&'a [Selection]>, executor: &'a Executor, ) -> crate::BoxFuture<'a, ExecutionResult> { let f = resolve_into_list_async(executor, info, self.iter()); @@ -292,7 +292,7 @@ where fn resolve_async<'a>( &'a self, info: &'a Self::TypeInfo, - selection_set: Option<&'a [Selection]>, + _selection_set: Option<&'a [Selection]>, executor: &'a Executor, ) -> crate::BoxFuture<'a, ExecutionResult> { let f = async move {