简体   繁体   中英

Graphql multiple mutations

I have 3 mutations in a query. 6 input parameters. If (profile_status === true), then send the mutation. And so for each mutation. How to do it?

mutation updateProfile(
   $input: UpdateProfileMutationInput!
   $input2: UpdateUserEmailMutationInput!
   $input3: UpdateUserPasswordMutationInput!

   $profile_status: Boolean!
   $email_status: Boolean!
   $password_status: Boolean!
) {
   @include(if: $profile_status) updateProfile(input: $input) {
     ...CoreUser
   }

   @include(if: $email_status) updateEmail(input: $input2) {
     ...CoreUpdateUserEmail
   }

   @include(if: $password_status) updatePassword(input: $input3) {
     ...CoreUpdateUserPassword
   }
}

I use @apollo/client . Include only works for fields. Is there a similar one for mutation?

From the specification :

The @skip directive may be provided for fields, fragment spreads, and inline fragments...

Implementation:

directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT

As you can see, it doesn't have MUTATION location - it's not implemented for mutations. If you are the developer of the server, you can always create your own schema directive ( guide for Apollo Server ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM