Fireship · @fireship
Apollo Angular GraphQL Optimistic UI
Uploaded July 3, 2018 · Length 7:27
Summary
Implementing optimistic UI updates with Apollo and GraphQL in an Angular app, including setting up mutations and queries.
- apollo angular
- graphql optimistic ui
- angular apollo
- graphql mutations
- apollo optimistic updates
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
a few weeks ago we built a graph QL
- 0:08
server with Apollo and nodejs if you
- 0:11
haven't seen that video make sure to
- 0:12
check that one out first to get a better
- 0:14
understanding of graph QL and Apollo
- 0:16
because in today's episode we're going
- 0:17
to be tackling the front end side of
- 0:19
this equation which involves querying
- 0:21
data and providing mutations with
- 0:23
optimistic updates in our angular app if
- 0:25
you're new here make sure to LIKE and
- 0:26
subscribe and send a thank you to Arjun
- 0:29
Yellen and Shelley who was responsible
- 0:30
for writing the code for this lesson to
- 0:33
get started let's first talk about why
- 0:34
Apollo and graph QL are awesome
- 0:36
technologies from the front-end
- 0:38
developer perspective
- 0:39
notice how when I click this heart
- 0:41
button that the count increases and then
- 0:43
a second later our server responds with
- 0:45
an error and then it revert back to the
- 0:47
old value that's known as an optimistic
- 0:49
update or latency compensation and if
- 0:52
you use firebase you're probably already
- 0:53
familiar with this because that's one of
- 0:55
the things that the SDK does for you
- 0:57
automatically but if you're not using
- 0:58
the firebase SDK this is a feature that
- 1:00
would be really difficult to implement
- 1:02
from scratch
- 1:03
Apollo angular makes it easy to
- 1:04
implement features like this plus we can
- 1:06
use it with any back-end data source
- 1:08
that we've set up in our graph QL server
- 1:10
if we open this project in be s code
- 1:12
you'll notice that we have a back-end
- 1:13
and front-end folder the backend is the
- 1:16
graph QL server that we built in the
- 1:17
first episode we'll go in there and make
- 1:19
some updates but for the most part will
- 1:21
be in the front end which is an angular
- 1:22
6 app in our friend and app we're going
- 1:25
to install Apollo angular boost which is
- 1:27
a client library that makes it easy to
- 1:29
set up graph QL on an angular app and
- 1:31
also a library called Apollo code gen
- 1:33
which will allow us to generate
- 1:35
typescript definitions from our server
- 1:37
side automatically which is another
- 1:39
really awesome feature that we'll see
- 1:40
here in a few minutes and lastly we'll
- 1:43
use the angular CLI to generate an NG
- 1:45
module for our graph QL feature then we
- 1:48
can go ahead and open up that module and
- 1:50
we'll want to import the apollo boost
- 1:52
library and add it to the imports array
- 1:54
in the ng module then we'll add a palo
- 1:57
boost to the constructor of this module
- 1:59
and call apollo boost create and then


