Question · JavaScript and React course · Module 10: React Ecosystem and Future

The useMutation Hook in Apollo Client

How does the useMutation hook differ from useQuery in Apollo Client?

Answer options

  • useMutation returns a function that triggers a mutation on demand, while useQuery automatically executes the query on render
  • useMutation does not return a function - it executes automatically on component mount
  • useMutation is for reading data, and useQuery is for modifying it
  • There is no difference - both hooks work identically, they only differ in name

You can check the correct answer by solving this task in the CodeWorlds game.