Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Flatten fields with user-defined resolvers #1752

Open
Labels
enhancementNew feature or request
@JakeNeau

Description

@JakeNeau

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

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp