Search code examples
react-nativegraphqlreact-hooksapollo-clientgql

Using multiple queries in a single useeffect hook in appolo graphql


I have to use multiple mutations in a single component and using 1 usequery hook; gql query definition is as follows.

Can anyone share the code for encorporating all these mutations in one usemutation hook.

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

Solution

  • 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)
       }`