React
Boost Your React Apps with Apollo: Beyond the Basics

Solution: onCompleted

PRO

Just like in the EditHabit form, we just need to use the onCompleted method in the mutation for creating an entry:

// src/AddEntry.js
const [createEntry, { error, loading }] = useMutation(CREATE_ENTRY_MUTATION, {
    refetchQueries: [{ query: HABITS_QUERY }],
        onCompleted: () => onAddEntrySuccess(),
  });

Now it's time to learn a brand new concept: caching in Apollo.

 

I finished! On to the next chapter