Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork512
Open
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 }}