Fix tests

This commit is contained in:
Blaine Bublitz 2020-05-10 20:25:49 -07:00
parent 14e3b4fe69
commit 9483ff14be
4 changed files with 54 additions and 15 deletions

View File

@ -447,7 +447,12 @@ pub use async_graphql_derive::InputObject;
/// ///
/// ```ignore /// ```ignore
/// #[Interface] /// #[Interface]
/// struct MyInterface(TypeA, TypeB, TypeC, ...); /// enum MyInterface {
/// TypeA(TypeA),
/// TypeB(TypeB),
/// TypeC(TypeC),
/// ...
/// }
/// ``` /// ```
/// ///
/// # Fields /// # Fields
@ -487,7 +492,9 @@ pub use async_graphql_derive::InputObject;
/// arg(name = "a", type = "i32"), /// arg(name = "a", type = "i32"),
/// arg(name = "b", type = "i32")), /// arg(name = "b", type = "i32")),
/// )] /// )]
/// struct MyInterface(TypeA); /// enum MyInterface {
/// TypeA(TypeA)
/// }
/// ///
/// struct QueryRoot; /// struct QueryRoot;
/// ///

View File

@ -140,7 +140,12 @@ struct HumanOrAlien(Human, Alien);
arg(name = "surname", type = "Option<bool>") arg(name = "surname", type = "Option<bool>")
) )
)] )]
struct Being(Dog, Cat, Human, Alien); enum Being {
Dog(Dog),
Cat(Cat),
Human(Human),
Alien(Alien),
}
#[Interface( #[Interface(
internal, internal,
@ -150,7 +155,10 @@ struct Being(Dog, Cat, Human, Alien);
arg(name = "surname", type = "Option<bool>") arg(name = "surname", type = "Option<bool>")
) )
)] )]
struct Pet(Dog, Cat); enum Pet {
Dog(Dog),
Cat(Cat),
}
#[Interface( #[Interface(
internal, internal,
@ -160,10 +168,15 @@ struct Pet(Dog, Cat);
arg(name = "surname", type = "Option<bool>") arg(name = "surname", type = "Option<bool>")
) )
)] )]
struct Canine(Dog); enum Canine {
Dog(Dog),
}
#[Interface(internal, field(name = "iq", type = "Option<i32>"))] #[Interface(internal, field(name = "iq", type = "Option<i32>"))]
struct Intelligent(Human, Alien); enum Intelligent {
Human(Human),
Alien(Alien),
}
#[InputObject(internal)] #[InputObject(internal)]
struct ComplexInput { struct ComplexInput {

View File

@ -9,7 +9,9 @@ pub async fn test_interface_simple_object() {
} }
#[async_graphql::Interface(field(name = "id", type = "i32"))] #[async_graphql::Interface(field(name = "id", type = "i32"))]
struct Node(MyObj); enum Node {
MyObj(MyObj),
}
struct Query; struct Query;
@ -52,7 +54,9 @@ pub async fn test_interface_simple_object2() {
} }
#[async_graphql::Interface(field(name = "id", type = "&i32"))] #[async_graphql::Interface(field(name = "id", type = "&i32"))]
struct Node(MyObj); enum Node {
MyObj(MyObj),
}
struct Query; struct Query;
@ -105,10 +109,14 @@ pub async fn test_multiple_interfaces() {
} }
#[async_graphql::Interface(field(name = "value_a", type = "i32"))] #[async_graphql::Interface(field(name = "value_a", type = "i32"))]
struct InterfaceA(MyObj); enum InterfaceA {
MyObj(MyObj),
}
#[async_graphql::Interface(field(name = "value_b", type = "i32"))] #[async_graphql::Interface(field(name = "value_b", type = "i32"))]
struct InterfaceB(MyObj); enum InterfaceB {
MyObj(MyObj),
}
struct Query; struct Query;
@ -176,10 +184,15 @@ pub async fn test_multiple_objects_in_multiple_interfaces() {
} }
#[async_graphql::Interface(field(name = "value_a", type = "i32"))] #[async_graphql::Interface(field(name = "value_a", type = "i32"))]
struct InterfaceA(MyObjOne, MyObjTwo); enum InterfaceA {
MyObjOne(MyObjOne),
MyObjTwo(MyObjTwo),
}
#[async_graphql::Interface(field(name = "value_b", type = "i32"))] #[async_graphql::Interface(field(name = "value_b", type = "i32"))]
struct InterfaceB(MyObjOne); enum InterfaceB {
MyObjOne(MyObjOne),
}
struct Query; struct Query;
@ -232,7 +245,9 @@ pub async fn test_interface_field_result() {
} }
#[async_graphql::Interface(field(name = "value", type = "FieldResult<i32>"))] #[async_graphql::Interface(field(name = "value", type = "FieldResult<i32>"))]
struct Node(MyObj); enum Node {
MyObj(MyObj),
}
struct Query; struct Query;

View File

@ -325,7 +325,9 @@ pub async fn test_subscription_fragment() {
} }
#[Interface(field(name = "a", type = "i32"))] #[Interface(field(name = "a", type = "i32"))]
struct MyInterface(Event); enum MyInterface {
Event(Event),
}
#[Object] #[Object]
impl QueryRoot {} impl QueryRoot {}
@ -380,7 +382,9 @@ pub async fn test_subscription_fragment2() {
} }
#[Interface(field(name = "a", type = "i32"))] #[Interface(field(name = "a", type = "i32"))]
struct MyInterface(Event); enum MyInterface {
Event(Event),
}
#[Object] #[Object]
impl QueryRoot {} impl QueryRoot {}