From the course: Learning Apollo

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Optimistic UI for faster updates

Optimistic UI for faster updates

From the course: Learning Apollo

Start my 1-month free trial

Optimistic UI for faster updates

- [Instructor] So what is Optimistic UI, really? Optimistic UI is handy feature that simulates the results of a mutation and populates it in the UI before the actual result arrives from the server. Once its result comes in, the temporary result is replaced. So the idea here is that Optimistic UI is creating the impression that the result is almost instantaneous. The reality is that there is still a short wait for the mutation to finish, but the user doesn't experience this at all. This this is really useful when the server is down or slow. So let's go ahead and code this. So the first thing we're going to do is go inside of AddContact.js and create the object that we need for Optimistic UI to work. So what you want to do is go just after variables again and above the update function that we created in the last video. And create optimistic response and that's going to be an object, which will be add contact. We'll use add contact and then pass the ID first name, the last name, and then…

Contents