React
Boost Your React Apps with Apollo: Beyond the Basics

Solution: onCompleted

Mute
Current Time 0:00
/
Duration Time 0:00
Loaded: 0%
Progress: 0%
Stream TypeLIVE
Remaining Time -0:00
 
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