Fix most warnings (#567)
This commit is contained in:
parent
2796d8df9a
commit
f247dbee48
10 changed files with 57 additions and 43 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#[cfg(test)]
|
||||||
use juniper::{graphql_value, GraphQLError, RootNode, Value};
|
use juniper::{graphql_value, GraphQLError, RootNode, Value};
|
||||||
|
|
||||||
#[derive(juniper::GraphQLEnum)]
|
#[derive(juniper::GraphQLEnum)]
|
||||||
|
@ -8,13 +9,17 @@ enum UserKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct User {
|
struct User {
|
||||||
id: u64,
|
id: i32,
|
||||||
name: String,
|
name: String,
|
||||||
kind: UserKind,
|
kind: UserKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[juniper::graphql_object]
|
#[juniper::graphql_object]
|
||||||
impl User {
|
impl User {
|
||||||
|
async fn id(&self) -> i32 {
|
||||||
|
self.id
|
||||||
|
}
|
||||||
|
|
||||||
async fn name(&self) -> &str {
|
async fn name(&self) -> &str {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,8 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn test_doc_comment_simple() {
|
async fn test_doc_comment_simple() {
|
||||||
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
|
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
|
||||||
let meta = DocComment::meta(&(), &mut registry);
|
let meta = DocComment::meta(&(), &mut registry);
|
||||||
assert_eq!(meta.description(), Some(&"Object comment.".to_string()));
|
assert_eq!(meta.description(), Some(&"Object comment.".to_string()));
|
||||||
|
@ -136,11 +136,12 @@ fn test_doc_comment_simple() {
|
||||||
&Value::scalar("Object comment."),
|
&Value::scalar("Object comment."),
|
||||||
"regularField",
|
"regularField",
|
||||||
&Value::scalar("Field comment."),
|
&Value::scalar("Field comment."),
|
||||||
);
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn test_multi_doc_comment() {
|
async fn test_multi_doc_comment() {
|
||||||
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
|
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
|
||||||
let meta = MultiDocComment::meta(&(), &mut registry);
|
let meta = MultiDocComment::meta(&(), &mut registry);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -153,11 +154,12 @@ fn test_multi_doc_comment() {
|
||||||
&Value::scalar("Doc 1. Doc 2.\n\nDoc 4."),
|
&Value::scalar("Doc 1. Doc 2.\n\nDoc 4."),
|
||||||
"regularField",
|
"regularField",
|
||||||
&Value::scalar("Field 1.\nField 2."),
|
&Value::scalar("Field 1.\nField 2."),
|
||||||
);
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[tokio::test]
|
||||||
fn test_doc_comment_override() {
|
async fn test_doc_comment_override() {
|
||||||
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
|
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
|
||||||
let meta = OverrideDocComment::meta(&(), &mut registry);
|
let meta = OverrideDocComment::meta(&(), &mut registry);
|
||||||
assert_eq!(meta.description(), Some(&"obj override".to_string()));
|
assert_eq!(meta.description(), Some(&"obj override".to_string()));
|
||||||
|
@ -167,7 +169,8 @@ fn test_doc_comment_override() {
|
||||||
&Value::scalar("obj override"),
|
&Value::scalar("obj override"),
|
||||||
"regularField",
|
"regularField",
|
||||||
&Value::scalar("field override"),
|
&Value::scalar("field override"),
|
||||||
);
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
@ -291,7 +294,7 @@ async fn test_derived_object_nested() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn check_descriptions(
|
async fn check_descriptions(
|
||||||
object_name: &str,
|
object_name: &str,
|
||||||
object_description: &Value,
|
object_description: &Value,
|
||||||
field_name: &str,
|
field_name: &str,
|
||||||
|
@ -329,7 +332,8 @@ fn check_descriptions(
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
)));
|
)));
|
||||||
});
|
})
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
#[cfg(test)]
|
|
||||||
use fnv::FnvHashMap;
|
|
||||||
#[cfg(test)]
|
|
||||||
use juniper::Object;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use juniper::{
|
use juniper::{
|
||||||
self, execute, graphql_value, DefaultScalarValue, EmptyMutation, GraphQLInputObject,
|
self, execute, graphql_value, EmptyMutation, GraphQLInputObject, RootNode, Value, Variables,
|
||||||
GraphQLType, RootNode, Value, Variables,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures;
|
use futures;
|
||||||
|
|
|
@ -14,13 +14,13 @@ pub struct Query;
|
||||||
)]
|
)]
|
||||||
impl Query {
|
impl Query {
|
||||||
fn users(exec: &Executor) -> Vec<User> {
|
fn users(exec: &Executor) -> Vec<User> {
|
||||||
let lh = executor.look_ahead();
|
let lh = exec.look_ahead();
|
||||||
assert_eq!(lh.field_name(), "users");
|
assert_eq!(lh.field_name(), "users");
|
||||||
vec![User]
|
vec![User]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn countries(exec: &Executor) -> Vec<Country> {
|
fn countries(exec: &Executor) -> Vec<Country> {
|
||||||
let lh = executor.look_ahead();
|
let lh = exec.look_ahead();
|
||||||
assert_eq!(lh.field_name(), "countries");
|
assert_eq!(lh.field_name(), "countries");
|
||||||
vec![Country]
|
vec![Country]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::{self, Debug, Display},
|
fmt::{Debug, Display},
|
||||||
sync::RwLock,
|
sync::RwLock,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,17 @@ enum UserKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct User {
|
struct User {
|
||||||
id: u64,
|
id: i32,
|
||||||
name: String,
|
name: String,
|
||||||
kind: UserKind,
|
kind: UserKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[crate::graphql_object_internal]
|
#[crate::graphql_object_internal]
|
||||||
impl User {
|
impl User {
|
||||||
|
async fn id(&self) -> i32 {
|
||||||
|
self.id
|
||||||
|
}
|
||||||
|
|
||||||
async fn name(&self) -> &str {
|
async fn name(&self) -> &str {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,7 +464,7 @@ mod dynamic_context_switching {
|
||||||
|
|
||||||
#[crate::graphql_object_internal(Context = OuterContext)]
|
#[crate::graphql_object_internal(Context = OuterContext)]
|
||||||
impl Schema {
|
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))
|
executor.context().items.get(&key).map(|c| (c, ItemRef))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,6 +1085,7 @@ mod named_operations {
|
||||||
#[crate::graphql_object_internal]
|
#[crate::graphql_object_internal]
|
||||||
impl Schema {
|
impl Schema {
|
||||||
fn a(p: Option<String>) -> &str {
|
fn a(p: Option<String>) -> &str {
|
||||||
|
dbg!(p);
|
||||||
"b"
|
"b"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>(
|
pub async fn execute<'a, CtxT, QueryT, MutationT>(
|
||||||
&'a self,
|
&'a self,
|
||||||
root_node: &'a RootNode<'a, QueryT, MutationT, S>,
|
root_node: &'a RootNode<'a, QueryT, MutationT, S>,
|
||||||
|
|
|
@ -23,7 +23,7 @@ Syntax to validate:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#[derive(GraphQLInputObject)]
|
#[derive(GraphQLInputObject, Debug)]
|
||||||
struct Point {
|
struct Point {
|
||||||
x: i32,
|
x: i32,
|
||||||
}
|
}
|
||||||
|
@ -33,28 +33,28 @@ impl Root {
|
||||||
fn simple() -> i32 {
|
fn simple() -> i32 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
fn exec_arg(executor: &Executor) -> i32 {
|
fn exec_arg(_executor: &Executor) -> i32 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
fn exec_arg_and_more(executor: &Executor, arg: i32) -> i32 {
|
fn exec_arg_and_more(_executor: &Executor, arg: i32) -> i32 {
|
||||||
0
|
arg
|
||||||
}
|
}
|
||||||
|
|
||||||
fn single_arg(arg: i32) -> i32 {
|
fn single_arg(arg: i32) -> i32 {
|
||||||
0
|
arg
|
||||||
}
|
}
|
||||||
|
|
||||||
fn multi_args(arg1: i32, arg2: i32) -> i32 {
|
fn multi_args(arg1: i32, arg2: i32) -> i32 {
|
||||||
0
|
arg1 + arg2
|
||||||
}
|
}
|
||||||
|
|
||||||
fn multi_args_trailing_comma(arg1: i32, arg2: i32) -> i32 {
|
fn multi_args_trailing_comma(arg1: i32, arg2: i32) -> i32 {
|
||||||
0
|
arg1 + arg2
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(arguments(arg(description = "The arg")))]
|
#[graphql(arguments(arg(description = "The arg")))]
|
||||||
fn single_arg_descr(arg: i32) -> i32 {
|
fn single_arg_descr(arg: i32) -> i32 {
|
||||||
0
|
arg
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(arguments(
|
#[graphql(arguments(
|
||||||
|
@ -62,7 +62,7 @@ impl Root {
|
||||||
arg2(description = "The second arg")
|
arg2(description = "The second arg")
|
||||||
))]
|
))]
|
||||||
fn multi_args_descr(arg1: i32, arg2: i32) -> i32 {
|
fn multi_args_descr(arg1: i32, arg2: i32) -> i32 {
|
||||||
0
|
arg1 + arg2
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(arguments(
|
#[graphql(arguments(
|
||||||
|
@ -70,7 +70,7 @@ impl Root {
|
||||||
arg2(description = "The second arg")
|
arg2(description = "The second arg")
|
||||||
))]
|
))]
|
||||||
fn multi_args_descr_trailing_comma(arg1: i32, arg2: i32) -> i32 {
|
fn multi_args_descr_trailing_comma(arg1: i32, arg2: i32) -> i32 {
|
||||||
0
|
arg1 + arg2
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: enable once [parameter attributes are supported by proc macros]
|
// TODO: enable once [parameter attributes are supported by proc macros]
|
||||||
|
@ -87,22 +87,22 @@ impl Root {
|
||||||
|
|
||||||
#[graphql(arguments(arg(default = 123,),))]
|
#[graphql(arguments(arg(default = 123,),))]
|
||||||
fn arg_with_default(arg: i32) -> i32 {
|
fn arg_with_default(arg: i32) -> i32 {
|
||||||
0
|
arg
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(arguments(arg1(default = 123,), arg2(default = 456,)))]
|
#[graphql(arguments(arg1(default = 123,), arg2(default = 456,)))]
|
||||||
fn multi_args_with_default(arg1: i32, arg2: i32) -> i32 {
|
fn multi_args_with_default(arg1: i32, arg2: i32) -> i32 {
|
||||||
0
|
arg1 + arg2
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(arguments(arg1(default = 123,), arg2(default = 456,),))]
|
#[graphql(arguments(arg1(default = 123,), arg2(default = 456,),))]
|
||||||
fn multi_args_with_default_trailing_comma(arg1: i32, arg2: i32) -> i32 {
|
fn multi_args_with_default_trailing_comma(arg1: i32, arg2: i32) -> i32 {
|
||||||
0
|
arg1 + arg2
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(arguments(arg(default = 123, description = "The arg")))]
|
#[graphql(arguments(arg(default = 123, description = "The arg")))]
|
||||||
fn arg_with_default_descr(arg: i32) -> i32 {
|
fn arg_with_default_descr(arg: i32) -> i32 {
|
||||||
0
|
arg
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(arguments(
|
#[graphql(arguments(
|
||||||
|
@ -110,7 +110,7 @@ impl Root {
|
||||||
arg2(default = 456, description = "The second arg")
|
arg2(default = 456, description = "The second arg")
|
||||||
))]
|
))]
|
||||||
fn multi_args_with_default_descr(arg1: i32, arg2: i32) -> i32 {
|
fn multi_args_with_default_descr(arg1: i32, arg2: i32) -> i32 {
|
||||||
0
|
arg1 + arg2
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(arguments(
|
#[graphql(arguments(
|
||||||
|
@ -118,7 +118,7 @@ impl Root {
|
||||||
arg2(default = 456, description = "The second arg",)
|
arg2(default = 456, description = "The second arg",)
|
||||||
))]
|
))]
|
||||||
fn multi_args_with_default_trailing_comma_descr(arg1: i32, arg2: i32) -> i32 {
|
fn multi_args_with_default_trailing_comma_descr(arg1: i32, arg2: i32) -> i32 {
|
||||||
0
|
arg1 + arg2
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(
|
#[graphql(
|
||||||
|
@ -134,6 +134,8 @@ impl Root {
|
||||||
),
|
),
|
||||||
)]
|
)]
|
||||||
fn args_with_complex_default(arg1: String, arg2: Point) -> i32 {
|
fn args_with_complex_default(arg1: String, arg2: Point) -> i32 {
|
||||||
|
dbg!(arg1);
|
||||||
|
dbg!(arg2);
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ where
|
||||||
fn resolve_async<'a>(
|
fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
info: &'a Self::TypeInfo,
|
info: &'a Self::TypeInfo,
|
||||||
selection_set: Option<&'a [Selection<S>]>,
|
_selection_set: Option<&'a [Selection<S>]>,
|
||||||
executor: &'a Executor<Self::Context, S>,
|
executor: &'a Executor<Self::Context, S>,
|
||||||
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
|
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
|
||||||
let f = resolve_into_list_async(executor, info, self.iter());
|
let f = resolve_into_list_async(executor, info, self.iter());
|
||||||
|
@ -274,7 +274,7 @@ where
|
||||||
fn resolve_async<'a>(
|
fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
info: &'a Self::TypeInfo,
|
info: &'a Self::TypeInfo,
|
||||||
selection_set: Option<&'a [Selection<S>]>,
|
_selection_set: Option<&'a [Selection<S>]>,
|
||||||
executor: &'a Executor<Self::Context, S>,
|
executor: &'a Executor<Self::Context, S>,
|
||||||
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
|
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
|
||||||
let f = resolve_into_list_async(executor, info, self.iter());
|
let f = resolve_into_list_async(executor, info, self.iter());
|
||||||
|
@ -292,7 +292,7 @@ where
|
||||||
fn resolve_async<'a>(
|
fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
info: &'a Self::TypeInfo,
|
info: &'a Self::TypeInfo,
|
||||||
selection_set: Option<&'a [Selection<S>]>,
|
_selection_set: Option<&'a [Selection<S>]>,
|
||||||
executor: &'a Executor<Self::Context, S>,
|
executor: &'a Executor<Self::Context, S>,
|
||||||
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
|
) -> crate::BoxFuture<'a, ExecutionResult<S>> {
|
||||||
let f = async move {
|
let f = async move {
|
||||||
|
|
Loading…
Reference in a new issue