Clippy cleanup
This commit is contained in:
parent
027fa368ab
commit
ed9486c072
15
src/base.rs
15
src/base.rs
|
@ -90,14 +90,13 @@ pub trait ObjectType: OutputValueType {
|
||||||
where
|
where
|
||||||
Self: Send + Sync + Sized,
|
Self: Send + Sync + Sized,
|
||||||
{
|
{
|
||||||
if name == Self::type_name().as_ref() {
|
if name == Self::type_name().as_ref()
|
||||||
crate::collect_fields(ctx, self, futures)
|
|| ctx
|
||||||
} else if ctx
|
.registry
|
||||||
.registry
|
.implements
|
||||||
.implements
|
.get(Self::type_name().as_ref())
|
||||||
.get(Self::type_name().as_ref())
|
.map(|ty| ty.contains(name))
|
||||||
.map(|ty| ty.contains(name))
|
.unwrap_or_default()
|
||||||
.unwrap_or_default()
|
|
||||||
{
|
{
|
||||||
crate::collect_fields(ctx, self, futures)
|
crate::collect_fields(ctx, self, futures)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -163,58 +163,58 @@ pub async fn test_multiple_interfaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
pub async fn test_multiple_objects_in_multiple_interfaces() {
|
pub async fn test_multiple_objects_in_multiple_interfaces() {
|
||||||
struct MyObjOne;
|
struct MyObjOne;
|
||||||
|
|
||||||
#[async_graphql::Object]
|
#[async_graphql::Object]
|
||||||
impl MyObjOne {
|
impl MyObjOne {
|
||||||
#[field]
|
#[field]
|
||||||
async fn value_a(&self) -> i32 {
|
async fn value_a(&self) -> i32 {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
#[field]
|
#[field]
|
||||||
async fn value_b(&self) -> i32 {
|
async fn value_b(&self) -> i32 {
|
||||||
2
|
2
|
||||||
}
|
}
|
||||||
|
|
||||||
#[field]
|
#[field]
|
||||||
async fn value_c(&self) -> i32 {
|
async fn value_c(&self) -> i32 {
|
||||||
3
|
3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MyObjTwo;
|
struct MyObjTwo;
|
||||||
|
|
||||||
#[async_graphql::Object]
|
#[async_graphql::Object]
|
||||||
impl MyObjTwo {
|
impl MyObjTwo {
|
||||||
#[field]
|
#[field]
|
||||||
async fn value_a(&self) -> i32 {
|
async fn value_a(&self) -> i32 {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_graphql::Interface(field(name = "value_a", type = "i32"))]
|
#[async_graphql::Interface(field(name = "value_a", type = "i32"))]
|
||||||
struct InterfaceA(MyObjOne, MyObjTwo);
|
struct InterfaceA(MyObjOne, MyObjTwo);
|
||||||
|
|
||||||
#[async_graphql::Interface(field(name = "value_b", type = "i32"))]
|
#[async_graphql::Interface(field(name = "value_b", type = "i32"))]
|
||||||
struct InterfaceB(MyObjOne);
|
struct InterfaceB(MyObjOne);
|
||||||
|
|
||||||
struct Query;
|
struct Query;
|
||||||
|
|
||||||
#[Object]
|
#[Object]
|
||||||
impl Query {
|
impl Query {
|
||||||
#[field]
|
#[field]
|
||||||
async fn my_obj(&self) -> Vec<InterfaceA> {
|
async fn my_obj(&self) -> Vec<InterfaceA> {
|
||||||
vec![MyObjOne.into(), MyObjTwo.into()]
|
vec![MyObjOne.into(), MyObjTwo.into()]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let schema = Schema::build(Query, EmptyMutation, EmptySubscription)
|
let schema = Schema::build(Query, EmptyMutation, EmptySubscription)
|
||||||
.register_type::<InterfaceB>() // `InterfaceB` is not directly referenced, so manual registration is required.
|
.register_type::<InterfaceB>() // `InterfaceB` is not directly referenced, so manual registration is required.
|
||||||
.finish();
|
.finish();
|
||||||
let query = format!(
|
let query = format!(
|
||||||
r#"{{
|
r#"{{
|
||||||
myObj {{
|
myObj {{
|
||||||
... on InterfaceA {{
|
... on InterfaceA {{
|
||||||
valueA
|
valueA
|
||||||
|
@ -227,20 +227,20 @@ pub async fn test_multiple_interfaces() {
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
}}"#
|
}}"#
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
schema.execute(&query).await.unwrap().data,
|
schema.execute(&query).await.unwrap().data,
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"myObj": [{
|
"myObj": [{
|
||||||
"valueA": 1,
|
"valueA": 1,
|
||||||
"valueB": 2,
|
"valueB": 2,
|
||||||
"valueC": 3,
|
"valueC": 3,
|
||||||
}, {
|
}, {
|
||||||
"valueA": 1
|
"valueA": 1
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
pub async fn test_interface_field_result() {
|
pub async fn test_interface_field_result() {
|
||||||
|
@ -286,4 +286,3 @@ pub async fn test_interface_field_result() {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user