Handle GraphQL Request Errors in Vue 3

Share this video with your friends

Send Tweet

What do we do with optimistic updates when things don't go the way we planned? Luckily, the Apollo client is smart and corrects the data, but it might not be clear to the user that their mutation didn't go through.

We can have our component emit and error event and that error can be handled by the parent component. In our case, we'll use a v-if to display a message that informs the user their request didn't go through and the updated values were reverted.