January 2019
Intermediate to advanced
460 pages
10h 33m
English
Apollo provides the great feature of being able to update the UI in an optimistic manner. An optimistic manner means that Apollo adds the new data or post to the storage before the request has finished. The advantage is that the user can see the new result, instead of waiting for the response of the server. This solution makes the application feel faster and more responsive.
This section expects the update function of the Mutation component to already be implemented. Otherwise, this UI feature will not work. We need to add the optimisticResponse property to our mutation, as follows:
optimisticResponse= {{ __typename: "mutation", addPost: { __typename: "Post", text: postContent, id: -1, user: { __typename: "User", username: "Loading...", ...Read now
Unlock full access