1. 13
    Use optimistic updates to build UIs that react immediately to user actions
    8m 12s

Use optimistic updates to build UIs that react immediately to user actions

Share this video with your friends

Send Tweet

In this lesson, we're going to explore the "optimisticResponse" option of Apollo's useMutation hook. Optimistic updates allow us to react immediately in the UI, as if the mutation succeeded. This provides a quick/responsive feeling to the user. Once we get the official response from the server, if it was successful, we leave the UI alone, because it should be unchanged, but if there was an error we need to rollback the optimistic updates we applied. This is where Apollo makes it very easy: as we'll explore in the lesson, Apollo has an optimistic cache layering mechanism, that automatically knows how to rollback any failed updates.