【问题标题】:Using multiple queries in a single useeffect hook in appolo graphql在 apollo graphql 的单个 useEffect 挂钩中使用多个查询
【发布时间】:2021-01-19 02:36:34
【问题描述】:

我必须在单个组件中使用多个突变并使用 1 个 usequery 钩子; gql查询定义如下。

谁能分享将所有这些突变合并到一个 usemutation 钩子中的代码。

const Edit_Profile=gql`mutation{
  changeName(
    name: "navaneeth"
  )
  updateAvatar(
    avatar_id: "11"
  )
   updateCity (
    city:"bglr"
  )
  updateAbout (
    about:"am lino"
  )
}

【问题讨论】:

    标签: react-native graphql react-hooks apollo-client gql


    【解决方案1】:
    const Edit_Profile = gql`mutation EditProfile(
        $name: String!
        $avatar_id: String
        $city: String
        $about: String
       ) {
        changeName(name: $name)
        updateAvatar(avatar_id: $avatar_id)
        updateCity(city: $city)
        updateAbout(about: $about)
       }`
    

    【讨论】:

    • edit您的答案解释此代码的作用以及它如何回答问题,以便它对 OP 以及其他有类似问题的用户有用。在 Stack Overflow 上不鼓励仅使用代码的答案,因为它们没有解释它是如何解决问题的。
    猜你喜欢
    • 2020-12-14
    • 1970-01-01
    • 2017-03-12
    • 2017-11-10
    • 2020-02-05
    • 2019-01-09
    • 2020-03-16
    • 2021-02-13
    • 2021-06-14
    相关资源
    最近更新 更多