简体   繁体   English

Graphql 多重突变

[英]Graphql multiple mutations

I have 3 mutations in a query.我在查询中有 3 个突变。 6 input parameters. 6个输入参数。 If (profile_status === true), then send the mutation.如果 (profile_status === true),则发送突变。 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 .我使用@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...可以为字段、片段扩展和内联片段提供@skip 指令...

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.如您所见,它没有MUTATION位置 - 它不是针对突变实现的。 If you are the developer of the server, you can always create your own schema directive ( guide for Apollo Server ).如果您是服务器的开发人员,您可以随时创建自己的模式指令( Apollo Server 指南)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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