Refetching a query using Apollo-Client throws an error

Solution for Refetching a query using Apollo-Client throws an error
is Given Below:

I am using Apollo-client to post a mutation to my graphql server. When the mutation is completed, I want to refetch that data. I tried using the refetchQueries argument in the useMutation hook, however I receive this error when I execute the code:

query option is required. You must specify your GraphQL document in
the query option.

This is the line of code that sends the mutation:

const [addUser, { data, loading, error }] =
    useMutation(ADD_USER_QUERY, {
        refetchQueries:[GET_USERS_QUERY]
    });

This is my query (the hardcoded arguments were to see if the issues was due to passing variables):

export const ADD_USER_QUERY = gql`
    mutation {
        createUser(name: "Albert Einstein", email: "[email protected]") {
            id
            name
        }
    }
`;

Thank you!

Alright so I figured out what the issue was. I had to pass an object with a "query" key in the refetchQueries array:

const [addUser, { data, loading, error }] =
    useMutation(ADD_USER_QUERY, {
        refetchQueries: [{ query: GET_USERS_QUERY }],
    });

It’s weird though because it isn’t mentioned in the ApolloDocs. They simply use an array…

// Refetches two queries after mutation completes
const [addTodo, { data, loading, error }] = useMutation(ADD_TODO, {

  refetchQueries: [
    GET_POST, // DocumentNode object parsed with gql
    'GetComments' // Query name
  ],
});

Does anyone know why that is?

Thanks!