'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?



Solution 1:[1]

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).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maksim Kuzmin