8000 mutable access to data in mutations · Issue #1656 · async-graphql/async-graphql · GitHub
[go: up one dir, main page]

Skip to content 8000
mutable access to data in mutations #1656
@michalmoc

Description

@michalmoc

Description of the feature

I'd like to access my data in Context mutably. I understand it cannot be done in Queries, because they are run in parallel (and anyway it would be bad design to mutate in query). But I believe the very point of Mutations is the ability to change data, and this is why they are supposed to be executed sequentialy.
A bit related to #1478.

Code example (if possible)

struct MutationRoot;

#[MutableObject]
impl MutationRoot {
    async fn do_smth(&self, ctx: &mut Context<'_>) -> Result<bool> {
            let data = ctx.data_mut::<MyOwnData>()?;
            data.change_smth();
            Ok(true)
    }
}

pub type FilesSchema = Schema<QueryRoot, MutationRoot, EmptySubscription>;

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

      0