Skip to content

Does Cynic support a single mutation running multiple queries? #511

Answered by obmarg
jman-schief asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jman-schief - i'm pretty sure this should be possible. You just need to use the rename attribute to tell cynic that m1 & m2 are actually the addComment fields. I tried putting your query into the generator and it gave me this, which hopefully illustrates the idea:

#[cynic::schema_for_derives(
    file = r#"schema.graphql"#,
)]
mod queries {
    use super::schema;

    #[derive(cynic::QueryVariables, Debug)]
    pub struct UnnamedQueryVariables {
        pub comment_body: String,
        pub comment_body2: String,
    }

    #[derive(cynic::QueryFragment, Debug)]
    #[cynic(graphql_type = "Mutation", variables = "UnnamedQueryVariables")]
    pub struct UnnamedQuery {
        #[arguments(

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@obmarg
Comment options

Answer selected by jman-schief
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants