-
-
Notifications
You must be signed in to change notification settings - Fork 499
Open
Labels
bugSomething isn't workingSomething
915C
isn't working
Description
Having multiple Resolver for a Complex Object and one of them having a flatten Attribute causes Unexpected Behaviour:
Expected Behaviour
Implementing Resolver A with [graphql(flatten)]
and Resolver B without and then Requesting a Field from Resolver B should only call Resolver B.
Actual Behavior
Before it calls Resolver B it calls Resolver A, although it does not need a field from it. Only happens if the flattened Resolver comes first in the ComplexObject implementation.
Reproduction
Here is some test code, which shows the problem
The first test implements the flattened Resolved first, while the second test implements it second.
// will fail
#[tokio::test]
async fn test_1() {
#[derive(SimpleObject)]
#[graphql(complex)]
struct Outer {
b: i32,
}
#[derive(SimpleObject)]
struct Inner {
my_int: i32,
}
#[ComplexObject]
impl Outer {
#[graphql(flatten)]
async fn a(&self) -> &Inner {
unreachable!("We called the resolver a")
}
async fn c(&self) -> i32 {
println!("Calling resolver c");
42
}
}
let schema = Schema::new(Outer {b: 10}, EmptyMutation, EmptySubscription);
let query = "{ c }";
schema.execute(query).await;
}
// will not fail
#[tokio::test]
async fn test_2() {
#[derive(SimpleObject)]
#[graphql(complex)]
struct Outer {
b: i32,
}
#[derive(SimpleObject)]
struct Inner {
my_int: i32,
}
#[ComplexObject]
impl Outer {
async fn c(&self) -> i32 {
println!("Calling resolver c");
42
}
#[graphql(flatten)]
async fn a(&self) -> &Inner {
unreachable!("We called the resolver a")
}
}
let schema = Schema::new(Outer {b: 10}, EmptyMutation, EmptySubscription);
let query = "{ c }";
schema.execute(query).await;
}
Specification
- Version: 7.0.15
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working