Fix most warnings (#567)

This commit is contained in:
Christian Legnitto 2020-03-14 00:01:02 -07:00 committed by GitHub
parent 2796d8df9a
commit f247dbee48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 57 additions and 43 deletions

View file

@ -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
}

View file

@ -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)]

View file

@ -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;

View file

@ -14,13 +14,13 @@ pub struct Query;
)]
impl Query {
fn users(exec: &Executor) -> Vec<User> {
let lh = executor.look_ahead();
let lh = exec.look_ahead();
assert_eq!(lh.field_name(), "users");
vec![User]
}
fn countries(exec: &Executor) -> Vec<Country> {
let lh = executor.look_ahead();
let lh = exec.look_ahead();
assert_eq!(lh.field_name(), "countries");
vec![Country]
}

View file

@ -2,7 +2,7 @@ use std::{
borrow::Cow,
cmp::Ordering,
collections::HashMap,
fmt::{self, Debug, Display},
fmt::{Debug, Display},
sync::RwLock,
};

View file

@ -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
}

View file

@ -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<String>) -> &str {
dbg!(p);
"b"
}
}

View file

@ -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>,

View file

@ -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
}
}

View file

@ -256,7 +256,7 @@ where
fn resolve_async<'a>(
&'a self,
info: &'a Self::TypeInfo,
selection_set: Option<&'a [Selection<S>]>,
_selection_set: Option<&'a [Selection<S>]>,
executor: &'a Executor<Self::Context, S>,
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
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<S>]>,
_selection_set: Option<&'a [Selection<S>]>,
executor: &'a Executor<Self::Context, S>,
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
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<S>]>,
_selection_set: Option<&'a [Selection<S>]>,
executor: &'a Executor<Self::Context, S>,
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
let f = async move {