-
-
Notifications
You must be signed in to change notification settings - Fork 507
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description of the feature
It would be nice to be able to use #[graphql(flatten)] with the fields with user-defined resolvers in complex objects. This would be useful for when two or more pieces of data are fetched by a resolver, and it is difficult to separate them (e.g. two values fetched from one row of a database in a single access).
Code example
#[derive(SimpleObject)]
pub struct ChildObject {
b: String,
c: String,
}
#[derive(SimpleObject)]
#[graphql(complex)]
pub struct ParentObject {
a: String,
}
#[ComplexObject]
impl ParentObject {
#[graphql(flatten)]
async fn child(&self, ctx: &Context<'_>) -> Result<ChildObject> {
// Some code that fetches data for and constructs the child object based on the 'a' field
}
}
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request