⭐ If you would like to buy me a coffee, well thank you very much that is mega kind! : https://www.buymeacoffee.com/honeyvig Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Saturday, November 8, 2025

Let's code a Netflix Clone with GraphQL Pagination! Reviewed by a NETFLIX ENGINEER!

 

0:00

hello internet i hope you're excited for this video i really am i'm excited because we are going to be

0:05

building a netflix clone using the same database management system

0:11

that the software engineers over there actually use that's right we're going to be using

0:16

data stacks which is built on apache cassandra and his netflix database management tool

0:23

of choice and we have an actual netflix software engineer that is here to review

0:28

our app and not only that we're going to be using the graphql api to communicate with our

0:34

database if you are new to grockewell this is the perfect video for you as i'm going to be taking you through

0:40

step by step into how to create tables and make queries we are also going to learn how

0:47

to use pagination and slicing pagination in a nutshell is a way for you to

0:53

get data page by page instead of getting it all at once similar to this that we will be building

1:00

in our app crafty well essentially enables you to get the fields you need from your datagraph without

1:06

any unnecessary overhead this helps keep network responses small and fast think of it like this

1:13

say we have this query right here now if we had loads of movies this would literally return every single movie in our database do we

1:21

really need all of this enter pagination when a client queries a paginated list field the server returns

1:28

only a portion or page of the list's element and then we have slicing slicing is essentially what

1:35

we're going to use in order to call as many genres as we want so for example when we have the page up

1:42

and loaded for the first time we're going to get four genres and as we move the cursor to the bottom of our

1:49

browser we're going to get more genres that are added to that list and more and more and so on okay okay so to recap that is a

1:56

netflix app that uses data stack built on apache cassandra to store our database

2:02

and we are also going to learn about graphql pagination and slicing but before we get going

2:09

please welcome our netflix software engineer who will be reviewing our app for us welcome hi i'm steven

2:17

and i'm excited to be here with onion to talk about how we do things at netflix okay awesome so please do stick around

2:24

for that we will be getting feedback throughout the app as we are coding along there is a lot to cover in

2:30

this tutorial it will be a long one but don't worry you're in safe hands i'm gonna be taking you through

2:36

absolutely everything step by step now as always before we get started let's actually break down what

2:43

we are gonna build in this tutorial we are going to start off by creating two tables a table that is

2:51

going to help us deal with genres and a table that is going to help us deal with the movies next we're going to get to

2:58

actually adding data for the two tables once we have added all our data it's time to start

3:04

building our app we are going to be doing this in react and using serverless functions

3:10

in order to get our data using graphql queries so in other words we're going to be making a

3:15

query to get all our genres and then we're going to be mapping out the genres onto

3:21

sections in our app next we're going to actually populate each section with the movies for that

3:27

genre with another query and after that we're going to be using pagination in order to

3:34

fetch more and more movies when we click the next button getting only six at a time

3:41

and then we're going to cover the limit part so limiting how many genres we get and

3:48

getting more or calling more if we move our cursor to the bottom of the page

3:53

and of course styling so doing things like using use state in order to show more information if we hover over

4:01

a movie card okay so i hope you're ready i'm really

4:06

excited let's do it please don't forget to like and subscribe to my channel

4:12

it would really mean a lot as it does mean i can keep creating more content for you guys

4:18

so let's do it okay so let's get to it now the first thing we need to do

4:24

is sign up to use the database to see all our data and what better database to use than one that's free of course for

4:31

beginners but also the one that uh netflix actually uses so that is a bit of trivia for you

4:37

uh we're gonna be using data stacks astra cassandra as a service um you don't need a credit

4:44

card to sign up so i'm just gonna go ahead and sign in please do sign up

4:51

uh here of course i'm not going to because i already have an account so like i said no credit card details

4:57

necessary um and it's free to use for beginners so let's do it so so we use cassandra a ton

5:06

at netflix it's uh it's it's great for a service like netflix that

5:11

needs to be able to scale globally and so ever since we launched into a 190 countries in 2017

5:21

we you know we need everything to work around the world all the time and so so a

5:27

a database like sandra's been really helpful to to make that work and

5:34

allow us to sleep at night at the same time i'm going to sign in just by clicking

5:42

here and this is essentially what you should see when you sign up now i'm going to create

5:50

my first database so i'm just going to click here and give our database a name let's go

5:58

ahead and call it netflix uh database or netflix clone

6:03

database to be more precise and let's just give it the key space i don't know netflix netflix

6:09

is fine great um please select your provider and region now this is

6:17

totally up to you whichever you want to choose and i'm just going to click europe middle east africa because that

6:25

is where i am and then click west europe and then of course create a database

6:34

and click continue ready for liftoff okay so there we go we have now created our

6:41

database it was that easy now i'm going to be using uh this is really cool actually so this

6:48

is stuff you need to remember we've got our cluster id which we're going to be using uh we're

6:53

going to be using a bunch of this stuff later but for now just be aware that my status is pending

6:59

but that's fine i'm going gonna show you something cool as soon as we have this

7:05

uh active so i'm just gonna perhaps speed this up uh i'm just gonna go

7:14

okay and we are active so let's do it great so we've got our netflix clone

7:20

database now i'm gonna actually use uh the graphql api and what is so handy about

7:28

data stacks is that it actually uh provides us the playground like complete with

7:34

um a it's basically just done it all for us okay so here we go the graphql api will

7:41

essentially allow us to interact with our data using the graphql types queries and mutations so we're

7:48

going to be doing this in the playground first in order to add data to our database

7:54

but then use the same queries to retrieve them but in our app okay we're going to add the data in this

8:01

playground that has been provided to us by data stacks we're going to add it add the data through the um

8:08

graphql api and then we're going to get it out using the same query language but in our app

8:13

so i just had to say that twice because it might be a bit confusing to people who haven't uh worked with this graphql playground

8:22

before so okay what i'm gonna do is just click here to open it

8:27

up oops i'm gonna click it though and then in another window though just really have to keep going back and

8:32

forward so again to the graphql api i'm gonna copy this link i'm gonna just

8:40

paste it in a new tab like this so now the first thing we need to do

8:45

is make sure we get our application token and put it in the http headers section at

8:51

the bottom of the playground so that we can you know like talk to our database so what i'm gonna do now is

8:58

go back to the netflix clone um and then i am just going to click on the

9:06

settings get an application token

9:14

i'm going to select a role so let's just put add on user and generate a token

9:20

i have actually generated them before but this is the token we need so i'm of course going to delete this

9:26

database by the way so please don't use my tokens they won't exist anymore please

9:32

do generate your own it wouldn't really uh make sense for you to use mine anyway right

9:38

because you want to communicate with your own database rather than using mine so in here the http headers

9:45

just uh where it says cassandra token i'm just going to paste that like so okay so we can now officially

9:52

communicate with our database okay so just so you know the forward slash graphql schema this is an api for

9:58

exploring and creating the schema so that is what we're going to do being in here and next we're going to be

10:03

looking at graphql slash key space so that'll be our key space name and this api is for querying and

10:09

modifying your cassandra tables using graphql fields so just remember

10:15

that when we start going we're going to start off with the uh graphql schema first to

10:21

start creating some schemas to start creating some tables so let's just go back

10:29

uh let's go back to the connect go back to the graphql api so now that we can communicate with our

10:36

database the first thing we want to do is create two tables i'm going to create a table that deals

10:42

with the genres and then a table that deals with the movies

10:48

so i'm gonna use please do use this uh here as a sort of like template and guide um however i'm just gonna go in

10:56

here and then delete this

11:04

okay so we're going to create our first table this is how we would do it we're going to write a mutation

11:09

so i'm going to write mutation and in here use reference

11:16

list create table uh making sure to use camel case

11:24

create table okay and in my table i'm gonna have to use that's right the

11:30

key space name we know that our key space name we called it netflix remember so make sure to use the

11:38

same key space name that you did uh when creating your database that is important

11:46

um and then let's give our table name as i've already alluded to up there our table name is going to be

11:54

reference list so i'm simply going to paste that as a string

12:02

if no not exist true and then we want partition keys

12:11

okay because i want to essentially be able to uh filter out our movies by genre

12:18

so this is what this is going to help me uh do i'm going to use the partition keys

12:25

and then the name label and then we have to give a type

12:33

it's going to be text we have different types but this the label is going to be text because i want to filter out the

12:40

partition key is going to be the label which is going to be text and then

12:50

we're going to have a clustering key too so this will make a lot more sense when we actually start dealing with the

12:56

uh databases database itself and the clustering key i'm going to

13:02

actually put the name value

13:08

type basic text because that's going to be a string

13:14

too and i'm going to give it an order of ascending

13:22

because i want these genres to be an ascending order uh based by the text okay

13:29

so this is what this is doing i'm creating a table that's going to deal with these genres essentially

13:35

so i'm going to create that table first i'm simply going to run it like so

13:41

and there we go we have created something it's called a reference list but just know that that's going to help us deal with the

13:46

genres i want to actually create two tables okay our next table is going to be for the movies

13:51

so once again i'm just going to use the same uh sort of i guess logic i'm going to write

13:57

a mutation i'm going to call it movies by genre

14:02

just to be super clear about what is essentially happening and let's create a table so once again we do that

14:10

and our table is gonna have a key space name i'm just gonna make sure that that's

14:15

below here though netflix

14:24

our table name just gonna be

14:29

movies by genre

14:35

if no exists true and then we're also going to have partition keys

14:43

we're gonna do it name genre

14:51

type basic text

14:59

and once again a cluster it's clear clustering keys and our clustering key is uh can we name

15:07

i'm going to do it by here and the year type is not going to be text it's going to be

15:13

an integer so basic int

15:24

order

15:32

and this time name title uh this title is going to be text

15:43

why is it not liking this

15:52

descending whoops type name title uh

16:00

yes that's going to be text and the order of this is going to be ascending so just like that once again

16:08

put that there okay so we have the partition keys we have the cluster and

16:13

keys next we need the values as well because the genre doesn't really need to

16:19

have values it's just the genre right however the movie does need to have values each

16:24

movie is going to have as of course it's going to have it's

16:30

going to be part of a genre it's going to have a year and a title

16:35

and then it's also gonna have so these you can't really cluster with these but there's just it's just

16:40

like data that is also attached to the movie if you will type

16:46

basic text

16:57

we're gonna have oops let's make sure to format that correctly of course

17:04

gonna have a synopsis i'm gonna have a duration which is gonna be an integer

17:12

synopsis i should probably spell that right synopsis duration and a thumbnail

17:20

let's call it our thumbnail now it's going to be more like a moo like mp4 but okay thumbnail for now

17:27

okay that's fine i'm happy with thumbnail let's just go with it you'd have to call it thumbnail if you don't

17:32

wish to okay so this is looking good let's

17:39

hit run ah wrong type argument value basic value within there's not a valid basic type okay what

17:47

did i do here ah yes i put this as a string whoops

17:52

this does not need to be strings so just keep that in mind

17:58

it's lucky that we have our messages in our lives and there we go so we've now added the

18:03

two tables we have the reference list we'll deal with genres and we've added the movies by

18:08

genre okay so now um

18:14

let's actually get to adding so that is it we've created the tables the next thing we want to do is start

18:21

adding the data so let's do it the next thing we need to do is in the graphql

18:26

playground we need to change the tab to now use uh another endpoint essentially

18:34

we need to edit the end of this to change from system to the name of your key space that we have okay so we have netflix we need to

18:41

do that luckily we can actually just take it from here as well so we've done the table we've

18:48

created it our two tables so here we go we don't really need to do

18:54

much because uh the platform is provided for us so that's really nice so i'm gonna go here and just paste this

19:02

new url that's gonna take us to our key space so just like that

19:08

and let's not forget that we also need our cassandra token so we can communicate with our database

19:13

like so great so now let's get to adding some data i'm going to do this by

19:20

running another mutation like so so we're gonna do the genres first again

19:25

uh i'm going to uh insert a genre so my mutation i'm just gonna call it insert

19:31

genre like this um genres and then i'm going to have an

19:38

action genre so i'm going to insert reference list thank you very much

19:44

and value

19:50

the value of it is going to be well i want to give a label because remember that is uh one of our

19:56

partition keys next thing is going to be the value and i'm just going to simply put that as

20:02

action so each reference list item that we insert it's going to have a label that says genre

20:07

and a value that says uh what the value of what we're doing right we're certainly a genre that has the value of

20:13

action so that is how i would uh do it essentially

20:23

and then i'm just going to simply put value value like so

20:31

if you really want to format it a little bit better this probably is the way to do it uh okay

20:39

so here we go if i run this now we have added one genre but we need to add a few

20:45

genres right so i'm gonna do that now we could just do them all at one time so we've added

20:51

action we don't actually need to worry about action anymore let's also add anime

20:56

i'm just gonna change this to anime a

21:02

comma here let's also have whoops

21:08

got anime let's have um award like award winners

21:20

i'm also gonna have children

21:27

let's give it the value of children and family then let's have

21:37

comedies comedies comment jesus for that correctly hopefully

21:42

uh comedies and then perhaps just copy all of these

21:48

again

21:56

okay okay from here and then

22:02

comedies let's have documentaries i hope i'm spelling all this right

22:07

documentaries document the more data the better okay

22:15

documentaries because we'll really fill out our

22:21

netflix uh app we're gonna have drama too

22:29

let's have dramas uh and let's have fantasy

22:46

and then just a few more i promise okay so we've got quite a few there just

22:55

maybe let's just do like a tiny bit more um let's have

23:06

french french um

23:15

horror horror

23:23

independent

23:34

independent music music

23:44

romance romance

23:51

and then i'm just going to put sci-fi and thriller so that's going to be it i promise um i want all the data and plus i've got

23:59

it so i might as well use it sci-fi

24:10

fi and last one thriller

24:19

thriller okay so um are you ready

24:28

are you ready let's go okay so we have all of our genres now created

24:34

this is looking good as you can see it was successful so let's carry on we've added the genres

24:43

now let's add the movies i'm not gonna make you sit here and watch me do all of them again

24:48

uh i'm gonna show you where you can get all this data because of course we have so many movies to add

24:53

you can think this is just the genres you can imagine how many movies there are right so we've added

25:00

the uh genres if you do want to actually retrieve

25:06

these genres you can do so simply um so if you did actually want to get all

25:12

these genres you would simply write this query get all genre i'm going to call it

25:18

um why not i can call it whatever i wish

25:25

and then get the reference list uh and then values

25:32

and i just want to get the value okay so the value as we know is what we called each genre like action

25:38

or something so then of course we need to search for it by value

25:48

label genre so there we go that's how we can

25:54

retrieve all the genres that we've just created so we can see what's in our reference list so they are all

26:03

there great okay also once again make sure that you are

26:08

in the netflix uh key space name if you're not then of course that won't work

26:14

make sure you're in the key space name of netflix great now let's create our um

26:21

first movie so once again i'm going to write mutation and let's call it insert movies

26:34

and the first movie that i want to create is inception so that's what i'm gonna

26:40

call it and then i'm gonna need to use insert a movie by genre and then let's get up some

26:48

um we need to put the value in uh and i'm gonna say

26:55

the genre for inception is psi phi the year is gonna be

27:03

2010 that's the release date the title of it is of course inception as a string

27:09

and sep chun like so let's make a capital um this

27:17

synopsis is is gonna be i don't know cobb steals

27:25

information from his targets by entering their

27:32

dreams okay let's give it a duration of one two

27:40

one minutes i have made that up and the thumbnail okay now

27:46

the thumbnail is uh i'm going to store all of my thumbnails so they're going to

27:51

be mp4 files on imager please feel free to store them whatever you want but i think this is quite nice and it just

27:56

means that you can use them because i'm going to make it public as well so this is what i i'm gonna do

28:06

so yeah so that's great and uh we we do basically that at netflix we uh

28:12

you know we don't provide the video files uh write inline like through graphql we you know we

28:18

provide urls to the files and then we store the files on a uh we call it a cdn a content distribution

28:24

network and so there's computers that netflix ships all over the world to your local

28:31

internet provider so so down the street at your internet provider they probably have one of netflix's servers sitting there loaded

28:37

up with netflix movies and so our special url is going to be

28:43

pointing you to the closest server that can give you your movie

28:49

here are just some of the uh mp4s i've stored on imager i'm going to give you the links so you

28:55

can have all of them check it out i mean it's some like literally just like a little clip that plays

29:01

and yeah i'm going to give you the links uh so please be able to use them the link to all of this is in the

29:07

description below please have a look at that where you can get all my data that i've kindly made for you so you can have and

29:14

you can share with your friends and blah blah blah just make sure to credit me okay because it ah that's a nice thing to do uh okay

29:23

so let's get the uh link for

29:30

inception um

29:38

i'm just gonna get that link here and then in the thumbnail part i'm gonna just

29:44

paste it as a string like this okay and then so we've got all of that

29:51

uh i just need to put value title okay

29:58

so now i'm just gonna add that like so and there we go we've added our first movie

30:03

now like i said i don't need to sit through all of this so i'm just going to get all the movies

30:11

and i'm just going to paste them in because i pre-made them and there is a lot so let's get rid of that

30:21

i'm going i'm gonna insert the action movies

30:27

click so that is how many i have added some of them are repeated

30:41

i'm going to add the anime movies so that is now

30:47

added once again as you can see there are some repeated

31:02

i'm gonna add the award-winning movies

31:14

i'm gonna add the children's movies by the way this is just me naming it uh just so we

31:20

can see what is happening but um we don't actually need to i could do it like that and it will still add

31:26

all these movies so just have a look and there you go okay so that is just for us uh it's just so everything's a

31:34

bit more readable but you can just use mutation if if you wish okay um

31:41

this will still work because you know we have uh arranged our data in such a way um

31:49

when we create each of our movies that it will know uh to

31:55

put it in the movies by genre table okay and that is thanks

32:02

to this right here and then of course we are going to filter them by

32:07

genre so i've just added the comedies now we still have a few to get through let's

32:14

do the documentaries next

32:23

so i'm gonna add

32:30

the documentaries

32:40

i'm going to add some dramas let's actually add we just had one drama for now

32:53

let's add some fantasy

33:04

i'm gonna also add some french films because everyone loves a french film

33:10

amy is a pretty good one i'm not gonna lie i've watched it a few times and then horror one of my

33:16

favorite genres um actually it's probably more thriller

33:21

but you know horrors don't know what kind of horror like if they're two graphic slasher ones i'm

33:26

not really into them if they're more psychological i think that's like a lot better right everyone

33:31

likes a psychological horror psychological thriller everyone loves some independent films

33:37

too so i put in entering red and war room and i'm going to put in some music ones

33:44

because you know why not it's our database and we can do whatever we wish

33:50

and then of course uh romance because romance is a very popular one too

33:56

so i'm just gonna shove in some romance movies and then i hope you guys appreciate this

34:02

getting this data um was quite uh long especially in getting all the mp4

34:10

files so if this doesn't get like a retweet or a sub at least i'll be pretty upset

34:18

okay so we've got these sci-fi films now there's a lot of those

34:24

and the thriller as well so i'm just gonna put in the thrillers too i think sci-fi has

34:30

probably got the most for sure um again one of my favorite genres and

34:38

thrillers okay perfect okay and now let's actually uh get the data back right so

34:46

you can see it now as we are going to be getting the movies by genre i'm going to show you how to do it in here

34:52

and then you can see how we're doing it doing it in our app okay because we're essentially going to be writing the same query just in our app

34:57

so i would use query um once again you don't have to name it if you don't want and we're going to get the

35:03

movies by genre and then i'm going to get the

35:09

value let's get sci-fi right so you might see that some of

35:15

these are sort of like auto completing for me this is something that i haven't shown you yet but i wanna

35:20

i'm gonna show you now it's quite handy it's quite a cool thing that comes with the playground

35:28

um so i'm just gonna do

35:34

yeah i'm just gonna order it for now i'm gonna show you some other cool stuff that we can do or dubai uh

35:42

yeah descending so once again i can use that um and then let's get back so these are

35:50

the values that i want to get back in my search let's get the year let's get the title

35:57

let's get the duration let's get this synopsis and let's get

36:03

the thumb now so if i click search oops what have i done here what's it not liking

36:12

oh yes oops that should wrap everything in here sorry okay

36:20

so there we go we now get all the moves by genre we get all the sci-fi movies we get the year title duration stops the

36:26

thumbnail if i delete these say we just want to get them by the value of year well then that's what we get okay or i

36:33

can do whatever i want i could just get the title and duration for example so these are

36:39

the values that i won't return cool right now check out these docs

36:44

because this is really cool movies by genre so that's the query that we are doing we can also get stuff like page state

36:50

which we will go into later as we are going to look at pagination and stuff and we also can

36:57

do options so if i pass through options this is really hungry handy the arguments here we've used

37:04

value as an argument i can't also use options

37:09

and then we need the curly braces so options and i could use limit for example this is just one of

37:15

the things i can use these are one of the things that to my disposal uh so i love these dogs it's really handy and it makes our life so much

37:22

easier and it says that i can pass through an integer so let's just pass through maybe two

37:29

and now let's run it there we go we got the first two so that is really cool i just should

37:36

have highlighted that earlier that is something of fun that graphql playground gives us it's all very neat

37:42

and it makes our lives a lot easier when working with data like this okay

37:48

so we've got our data in i think it's now to move on to part two part two is gonna be where we start

37:54

building our app and start getting this data into our app so we can use it and of course looking at pagination

38:00

too okay so the first thing i'm going to do is

38:06

navigate to a directory of my choice and i'm just going to create a uh

38:12

netflix app using create react app so sorry mpx create

38:18

react app and then let's call it netflix

38:24

data stacks uh and click enter so that is all happening now

38:32

and uh create react app is essentially creating a project for us that's configured already uh to use and has

38:40

all of these set up you needed to create a react app essentially we are going to be doing this with

38:46

create react app and we're also going to be using serverless functions in order to get our data so if you haven't used serverless

38:52

functions before netlife serverless functions to be exact i do have a separate tutorial specifically on this

38:59

but um if you follow me step by step then perhaps you won't need to so please do follow me and if you do get really

39:05

stuck then use the other tutorial that i talked about okay so once again i'm just

39:11

going to probably edit this out because it's taking a while okay and we are done let's open up our

39:19

project so i'm gonna open up using code dot which is a shortcut i have for vs code which would open up my

39:26

project whoops i need to make sure i'm actually in the project first so uh netflix

39:33

data stacks clone okay and now code dot perfect

39:40

so you will see here our project configured thanks to create react app which is pretty handy we have

39:47

the package json here which has all these scripts that we need as well as the dependencies that came

39:53

with this it has some libraries we're not going to be doing any testing for this project i'm actually going to delete some of

39:59

these files just to make our lives a bit easier i'm going to move that to trash i'm going to move the web report vitals

40:06

to trash we don't need the logo so i'm just going to delete that too i'm not going to do testing so i'm going

40:13

to delete the app test js file and then delete the index css

40:18

file we're going to do all our styling and app css so now of course we need to get rid of

40:24

this i also don't really like using semicolons in my project so i'm just gonna

40:29

delete those two oops why did that happen

40:34

so those are now gone uh we don't have this file anymore and then in the app js file once again

40:42

to delete those we don't have the logo anymore so delete that otherwise uh

40:48

everything will break i'm going to keep that so you can see i guess what this looks like but we don't have the logo

40:55

and i don't really like using this we use a function expression const app uh there we

41:02

go it's a personal preference you could have kept it as it is if you wish and click save cool

41:10

okay so now if i run npm run dev is it dev i think it's start

41:17

i always get them confused stopped uh npm run start

41:25

i've just used the script in order to start my app

41:33

so uh so so our netflix app has has evolved over the years but it's still the

41:38

basic home screen structure has it hasn't really changed that much you have a list of lists of movies

41:46

and at netflix uh as an engineer one of the first words you you you learn and you hear and you're

41:52

like what are they talking about is lolomo everyone's talking about the lolomo like what in the world is the logo

41:58

it's a list of list of movies that's just the netflix homepage

42:05

so now on localhost 3000 well there we go obviously i've deleted

42:10

the logo and the font so that is what our create react looks like and i've also got rid of some styling but this is just to you

42:17

know show you that it's working um i am now going to get rid of everything else

42:23

so i'm just going to delete all of this because for now we don't need it

42:28

i'm just gonna put just empty elements and like so

42:36

and then i'm also gonna delete everything in here because i really want to start from scratch great okay so the first thing i think we

42:43

should do is just make sure that we can actually get the data right because when we have the data

42:49

everything um should be a lot easier for us so

42:54

the first thing that i am going to do is actually uh use

43:01

um yes okay we're gonna use netify functions as i said so we

43:07

need to get the netlify cli i'm going to install it globally uh for

43:13

those of you who haven't used before netlify cli is the thing we are going to need in

43:19

order to make netflix surplus functions so

43:24

in here i'm going to start a new tab i'm just going to install it globally so

43:30

that's what the g is for i'm installing the netlife command line interface or cli as i like to call it so i can use

43:38

the netlify command line interface so once again we need to wait for that to install

43:49

okay so once that's done let's just check that has worked i'm just write notify and great you will see all the commands

43:56

that we have to our disposal uh i'm gonna have to use netlifydev

44:01

and this is gonna help me inject all the uh i guess secrets that we need in order to get our data so saying that

44:09

let's make a dot env file in the root of our project like so and in here i'm going to store

44:17

all my secrets okay so let's go our cassandra token once again i will be deleting this

44:26

please don't use it uh and i'm just going to whack it in here now what should we save this as

44:35

um let's save it as astra token

44:41

like so okay so we could do it like this uh let's just

44:48

leave that up here for now maybe astra just be very explicit

44:54

database

45:00

astra database application token now so just think of it like we just what we want to do is communicate with this

45:06

right we just want to send queries to the same thing so what did we need to do for this well we needed the token

45:12

and we needed the endpoint so i'm simply just going to take the point really

45:18

astra graph ql and point

45:28

and paste it oh there we go cool so that is all these secrets that

45:34

we need um now let's create our first netlify

45:41

function so once again in the root of our project i'm going to call this functions like so

45:51

i'm also going to have to create a netlife file once again please do refer

45:58

to my tutorial or notify functions this is essentially just sort of like configuration

46:04

um so we're going to have to specify a command

46:12

if you run functions is going to be essentially so

46:18

we this is my functions folder essentially so what i've named it here i have to name it

46:24

here and then publish well i'm just going to publish it

46:29

to a directory called build okay

46:37

so that is everything that we need in here make sure to create that in the root of

46:42

your file and now

46:48

we need to create our first function so i'm gonna write a function let's call this uh get

46:54

genres js this is essentially the syntax for

47:00

writing a serverless function you need to write export handler like so uh exports plural

47:08

and then it's an async function um i'm just gonna do this empty for now

47:14

because that is fine we don't need to pass through anything but essentially you can password like event context

47:21

um to pass stuff back and forward from your front end um let's write our first query so we

47:28

know how to do this because we've already written our first query i'm gonna have to write this in

47:33

i'm gonna write it like in back ticks like so oops const query

47:40

and all i'm going to do is remember the last query that we wrote so we don't know

47:45

what movies we want to get by genre the query was it looked like this

47:52

query and then we can name it i'm gonna name it so we know what we're dealing with get all genre

48:01

but we don't have to okay like that is just up to you on how readable you want to

48:07

make this and then we need to get by reference list

48:15

value label

48:25

genre okay

48:32

and then let's just i think that's fine and then let's just

48:39

return the values value because that's what we did

48:46

so that is our query if i put this in here and wrote that query and got it we would

48:53

get all that so essentially that's all we're doing okay we're sending this query to this endpoint

48:58

but from our project okay it really is that simple okay so now we need to make

49:06

that query to actually fetch the response so const response um await

49:12

and then i'm just gonna use fetch so we need to actually in we need to import fetch so we can

49:19

use it um and i'm gonna get the url

49:26

which is our end point so const just going to tab this out

49:35

const url equals and then i'm going to use process env and what did we call it

49:42

astrograph ql endpoint okay so that's our url so we're going to go to that url

49:48

and we're going to get our query okay we're going to pass sorry we're going to pass through the query so it makes it on

49:54

that endpoint that's really um it but of course we need to pass through a

50:00

lot more information here like our application token and we also need to stringify this okay so first off though let me just

50:08

import uh the package node fetch is what we need to

50:13

import npmi node fetch yeah okay node fetch

50:21

so let that import for now great so now we can use it let's just uh

50:29

const fetch require

50:35

require choir

50:42

choir sure whatever require no fetch why can't

50:48

i type anything nerd fetch okay

50:56

so cons response equals await fetch and then like i said we need to pass a lot more things in here than just the query

51:03

so let's open up our little object it's going to be a post okay because we are posting um

51:13

the query i'm just gonna do a single quote but do you know what i'll i'll clean this up

51:19

later for you um let's not waste time too much time so it's going to be post and then in the

51:25

headers just like we did in our playground

51:33

um i'm actually going to put content type

51:44

content type uh what's it application

51:54

json

51:59

and then x you could just copy it so i'm just literally going to copy what

52:05

it says here cassandra token and then process env

52:13

and again what did we call it called it this i'm just gonna post that

52:20

okay so that's what we need to pass through the headers and then of course the body is gonna be our query

52:28

but we're gonna use a json string of 5k because we need to stringify the query so just like that cool

52:37

so that is what we need to do um and then i'm just going to use a try

52:44

so that we uh can get the response body to

52:51

await response jason and fonz jason is going to be assigned to response body

52:58

um and then we're going to return a status we're going to actually say the

53:04

status code is going to be 200 um and then body is just going to be

53:10

again jason stringify

53:16

response body cool

53:24

so i'm going to try that i'm going to catch uh any errors so this is how you would

53:30

catch the errors i'm just gonna close all of the errors

53:42

and return again we are going to hard code status

53:48

code 500 and body jason stringify

53:57

stringify the errors cool

54:05

so that's it um we have written off a service function we are just

54:11

writing a query to get all the genres okay that's all we are doing now in our app.js

54:19

file let's try get that information

54:25

so up here all i want to do is fetch uh the data

54:32

that comes back from the get genres function so i'm going to write const future data

54:37

equals it's going to be an asynchronous function

54:43

and then i'm going to once again so i'm going to get the response uh and i'm going to fetch

54:51

um and then i need so if i actually ran this i should probably show you that

54:57

first let me just console log this out now i'm going to stop the app running

55:02

and i'll see and this time i'm going to use netlify dev to start the app okay so i've

55:09

stopped the app and i'm using netlifydev in order to get going so as you can see

55:15

i've injected the application token i've injected the endpoint okay

55:21

and now so it's just opened up again if i visit forward slash uh

55:28

dot netlife functions i've also used it quite a few times get genre

55:37

enter process is not defined okay i've

55:43

obviously misspelled something ah process

55:51

there we go we have got all our data so now of course all we need to do in the front end is

55:58

just use this url to get that data into our front end so that is what i am doing

56:03

here essentially so fetch and then i'm just gonna

56:09

actually just copy this because that's all i really care about

56:16

fetch this url okay and then um now let's just just fetch it for now

56:25

we're not gonna bother doing anything uh quite yet so we're gonna fetch that

56:32

data and then [Music]

56:38

fetch the data and then we're gonna um we need to get the response body

56:46

again response body equals

56:53

uh await response jason okay and then once we have it

57:01

we just want to set the genres so i'm going to use use state for this

57:06

const genres set genres equals

57:12

use state and let's start off as null and of course we have to do

57:19

uh we have to import use state from

57:27

react so you've got use state now let's set the genres to be the response

57:35

body our response

57:43

body um i think that's what we want to do let's actually console.log what the

57:48

response body is

57:56

okay and then of course we need to put them in a use effect so we just affect

58:09

fetch data uh okay so we've got use effect here okay

58:16

cool so i've consoled blog the response body let's go back to localhost 8888

58:25

i'm just going to inspect the page to view our console log so it's no longer on localhost 3000. we're using localhost

58:31

888 and whoa okay that's because fetch data let's just uh put the empty array as a dependency

58:38

otherwise it's going to keep calling our data there we go so our data great but we just want the values here

58:46

so i'm going to have to put responsibility data reference list values

58:51

so let's do that response body data

58:56

reference list values okay so now if i actually um console log this

59:06

well yeah that's what we want we want an array of all of these objects okay so perfect we've got it and we've

59:14

set it so now we can use it it's saved under genres cool so what are we gonna do

59:22

now well i think we should

59:27

um okay yeah okay let's actually map out each row let's do that

59:36

so i'm going to i guess create a component so here

59:44

i'm going to call this components

59:50

and i'm going to call this a section js okay so const section equals

59:57

um there we go and of course we need to export it so export default section so we can use it

60:05

great so we've got our section and for now i'm just gonna return

60:11

a div and that div is gonna have the section genre

60:18

um so now if i import it in here import a section

60:26

from um components

60:33

section and now i'm just going to return it like so

60:54

all right okay sorry i need to put section components in the source directory i'm going to put it there okay

61:02

so great so now yes so now i'm in app.js and i'm going into

61:09

components and i'm going to section so that should work okay so there we go section genre i

61:15

have one section in there but i want to map out each uh section based on how many genres we have right

61:23

so what i'm going to do and i'm also going to pass through this section uh so in

61:30

here what i am actually going to do is um

61:40

how should we do this i guess if genres

61:46

exist then

61:53

we want to go into we want to essentially map each one out so if that exists

62:00

genres exist uh we want to get these genres we want to get the

62:07

its values right so

62:13

object values of genres and we're gonna map

62:21

each genre

62:31

onto the section i'm going to pass it through the genre value

62:42

so each genre's value so before i do this what oops okay it's obviously not liking

62:50

this already object genre oops

62:59

okay so once again if i actually let's

63:06

console log this out or i can just do it here console

63:14

oops genres

63:23

so here we have our genres i want to essentially pass this through each time

63:30

okay so that is how i would do it for each of the genres

63:37

i want to get each individual genre or each individual

63:42

object and i just want to pass through the genres value so this is what i'm

63:48

passing through so i guess it's the uh property name

63:54

values value if you want to be precise okay so now i just need to pass

64:02

through the genre into the section so i'm going to destructure the prop like so

64:07

oh sorry yeah the genre that's fine and i'm just going to put genre

64:13

so now if we click save easy right

64:20

please do have a go at this if you need that is simply how i would map out

64:27

each of the uh names onto each of these sections so if you've got your section right um

64:34

the next thing i want to do is get the movies for

64:40

each section or each genre so now let's go into the section and we're going to do

64:46

that in here let's actually create our other function um

64:52

while we're here so yeah let's do that first okay so this time i'm gonna call this

64:58

con function let's call it get movies js okay

65:04

and i am literally just gonna go in here and copy all of this and paste it because it's

65:10

pretty much the same not really but uh it gives us a good sort of like boilerplate

65:16

and place to start right so we're gonna have to again make a query so the query we're gonna

65:23

write now is what's gonna be the query to get movie by genre so the query

65:31

is uh movies by genre

65:39

and then well

65:44

i'm just gonna let's just do sci-fi first okay so i'm gonna search for psy

65:50

phi and that's going to be it for now and then i'm just

65:57

going to return the values of uh title just just to see what is happening so

66:03

essentially once again i am just doing it

66:09

oops it's got authentication

66:18

and make sure that we are in the right

66:26

end point argument value with the type

66:33

okay value see the docs again so movies by genre

66:40

values i can get the

66:53

so it's quite handy probably doing everything in here first so those are the films that i can get um

67:00

great we can get the title what else were the values year title once again let's refer to the

67:07

docs if you wish your title duration synopsis thumbnail year title uh

67:15

i've already forgotten duration uh synopsis

67:21

thumb nail i think that was it okay so now we'll get all that

67:27

information um i can of course

67:33

maybe uh order it as well so let's shall we do that sure

67:39

just make a comma order by and then let's put

67:46

yeah descending like this so it actually is already by

67:53

default but just so you know and the one thing that i will actually do when we do the pagination

67:58

um is uh shall we do it here let's just see if

68:05

this is working for now and then i'll show you what i mean so i'm just gonna paste this query in instead

68:11

so that's the query we're going to be making this time i'm going to keep the rest the same

68:16

save that and now if i go to forward slash dot netify

68:23

functions get movies

68:31

all right okay we need to restart the app so cancel that nullified dev

68:38

okay injecting injecting injecting press enter press enter

68:44

press enter uh okay so now

68:49

great so that is all the information you need great we're getting all the movies in sci-fi so once again now all i'm gonna

68:58

do let's get rid of some of this stuff that's our function great

69:04

uh i haven't started anything yet so i don't need it i'm actually just going to copy most of the stuff i did here so i'm just

69:10

going to copy all of that and put it in the section

69:16

um so once again we need to import these up here

69:24

and this time when we fetch the data i'm not gonna well let's actually just console.log what's coming back first

69:30

console log response

69:36

body um okay

69:43

oh yeah sorry oops uh we need to get movies

69:50

okay uh okay cool so now if we refresh um

69:58

once again so it's getting the movies but it's getting it this many times right because we have one two three four

70:03

however many sections there are that's how many times getting the data which um it's fine for now it's gonna

70:09

give us the sci-fi movies each time but we're gonna change that so now great we're getting all the movies

70:15

fantastic sci-fi movies done um okay let's actually maybe do a little

70:22

bit of styling in here just the smallest amount so we want to get the response

70:30

data movie by genre movies by genre of value so response body data movies by genre

70:38

value right

70:44

why is it undefined values sorry

70:52

cool cool so that's what we want it's an array of objects amazing and let's set that as

70:59

set movies and then pass through just pass through that so that's

71:06

we're going to set that so now that's going to be set as movies uh const movies set oops set

71:14

movies this is me just using use state uh equals use

71:22

state and we're going to start with null so we've got our movies now

71:30

so okay i'm gonna have to do some more mapping

71:40

okay so we're gonna have the genre and then if movies exist

71:49

so let's get our curly braces uh so if movies exist

71:57

then we want to essentially um we could create

72:04

a card here do you want to create a card

72:10

no let's just make a card in here i'm just going to make a div

72:16

for now and in this div

72:23

hmm another title and then let's have

72:35

actually okay fine i'm gonna call it uh okay let's give it a class name because we're gonna have to

72:42

make them appear in line i'm gonna call it a uh movie section

72:49

so it's actually the first signing we've done so far i'm gonna grab it dot movie section

72:57

and i'm just gonna make it display flex for now so they don't stack up but they appear in a row

73:03

and okay so if movies exist we want to show the movie section and then we're going to grab the movies

73:09

i'm going to map

73:16

oops we're gonna map um for each movie

73:24

uh and i'm also gonna have an index actually for each movie that resists in our movies array i am going

73:32

to ah let's just create a card element it's

73:37

probably easier it will be a lot less messy so in the components i'm going to just create a card.js file

73:44

and once again const card equals

73:51

and then export default card like so and in here i'm just going

73:57

to return for now a card okay so it's gonna look

74:05

something like this and i'm just gonna pass through what should we pass through for each card okay we're gonna

74:11

get the card itself let's give it a key of index and then

74:18

uh we're gonna let's just pass through the whole movie object okay like so which means that in here

74:25

i'm gonna just destructure the movie um

74:30

and then in here let's just have like an h2 tag maybe even smaller

74:36

let's make an h4 tag that has the movies title

74:46

movie duration and then just a quick mp4 file so

74:52

i would do this like so have a video

75:08

um

75:15

and the sauce is going to be sauce movie

75:23

thump now uh and of course it's going to be a

75:29

video so i need to say that type video mp4

75:36

file okay so i think for now this could be

75:44

fine um obviously we have a lot of styling to do and for card from let's get it from the

75:51

components cool we're in the component so that's all we need to do

75:57

okay and great so now

76:07

for action and anime and award-winning and children and family and everything

76:13

we have this sci-fi movies cool we're getting somewhere now i just need

76:20

to make sure that we get the right movies for each section so i'm gonna do so like this

76:29

um okay here's our section and then it's to get movies we're gonna

76:36

have to pass through the genre too right so i'm gonna have to open this up like

76:42

so um method it's going to be post

76:50

and the body

76:55

jason stringify uh and i'm going gonna actually pass

77:01

through into the body the genre like this um okay yeah that should be fine

77:09

so we're gonna pass that through into the body into the get movies uh um serverless function

77:18

so now i need to get event here okay i'm just gonna console.log event

77:26

uh and show you what happens so now if i just refresh the page there we go

77:33

so this is what is coming back this is my event uh and you will see

77:48

get movies

77:57

okay the body genre thriller

78:05

okay so that's what we want we want to get this word right here so if i go event

78:14

body um let's actually make it clearer that this

78:19

is what is coming back once again we just need to refresh that

78:26

page so now event body is genre romance great

78:31

so obviously if we want to get genre we would have to go like that and i'm just going to say this is const

78:38

genre we can even actually maybe neaten this up a little bit

78:44

so i can go like const body equals um you can use jason

78:52

pass event body so i'm just going to break it up a bit event body so that this means i could

78:58

just book body genre and i'll get the genre um so we have the genre now and the next

79:05

thing so instead of passing it through here i'm just gonna pass through the genre so

79:11

i'm gonna do it like this genre um will that work

79:21

let's let's just see

79:29

okay yeah i need to wrap this again in jason stringify okay because we need to string

79:36

a fire in order for it to work in the query so there we go so now for action i'm

79:44

actually getting action films um this is pretty epic uh for award winning i'm getting the

79:51

award-winning films for children and so on and so on and i'm actually getting the right films this is

79:56

great okay this is so good and exactly where i want to be

80:02

so i'm passing through the genre from the front end to my function by using a vent okay so

80:08

i'm passing it through body to body i guess body to event yeah nice

80:16

so let's just get rid of uh no we don't need to get rid of that let's keep everything as it is cool so we've got that um

80:24

the last thing i want to show you before styling this up is how i would do pagination

80:30

and how i would essentially get so say we only want like four um let's say we only want

80:38

four genres to load and i want the rest to load if i put my i guess cursor at the bottom of the page

80:46

so i would do so like this what should we do first let's do the pagination first

80:52

so let's go back to the section in here and ah just like we did

81:00

in the playground so get moves by genre so now i'm going to go back to the dots and you remember when we had options

81:06

here well i'm going to want to get the page size and the page state so right here or wherever really i could

81:13

just go options

81:18

and then page size and let's say i want the page size to come back with two

81:24

well i'll simply do that i can get two but then say the first page comes back with these

81:30

two how do i get the next two well i could use page state to help me

81:36

with this so i'm just going to put page state here and click there

81:41

so now we have the next pages state okay so aqua and to upgrade

81:48

are my uh two films that come back on page one and if i now put page state

81:56

and use this uh sort of id if you will

82:03

i get the next two and to get the next two well i just use this

82:11

so pagination on the the lolomo is is really important and netflix you

82:16

you might be watching netflix on your phone or your tv and your laptop

82:21

and these are all very different the the ui has different needs on your phone you only see a few

82:28

you know a few movies on a time at a time in your uh in your home screen whereas and if you

82:34

open up netflix on your laptop you might see a whole lot also your you know your internet

82:40

connection on your phone probably isn't going to be as stable as the broadband connection that your your tv

82:45

might be plugged into so pagination allows us to to be flexible

82:50

for these different these different uis that you might be using and so you can fetch from the device you

82:58

can get just you know just a few movies at first like just the initial screen and then you can load as the user starts

83:04

to scroll around you can load the ends of the rows you can load the the movies that are down at the bottom

83:10

of the page later so it really is that easy and we're

83:15

going to use this in our query so back in the

83:20

[Music] get movies query right under here

83:26

options i'm going to put page size

83:34

and let's say six uh and for now

83:43

i'm just going to put page state like so so let's see if that works let's go back

83:50

here and we should only get six one two three

83:55

four five six perfect now i'm going to have a button here and perhaps this maybe

84:02

make these a little bit smaller because they're not very easy to work with at the moment so let's just do that now

84:12

movie section card and let's maybe style the card

84:21

i'm just going to put class name card for now

84:31

i've got card and put width 100 pixels okay just just for

84:39

now um and then of course the video

84:44

itself with a hundred percent

84:52

okay so i'm just going to put a quick button here in order for us to get the

84:57

next six and the next six and next six for now on i'm aware this looks horrible

85:03

but um i want to get all the heavy lifting out the way first before we start styling

85:10

so back in this section um i'm literally just going to make a div that says

85:20

sorry div and i'll give it the uh class name of more

85:28

button and for now once again i'm just going to make it look horrible

85:38

more button width 100 pixels

85:44

height 100 pixels background color

85:52

red so there's our if there's a button if i click this i want to get the next six

85:58

so in our section um well i need to figure out a way to get

86:05

the next page state right so how are we going to do this in the fetch

86:12

data when i when i get the movie genre i also

86:23

i need to set the um page state okay so i'm going to get the

86:29

page state uh const page

86:35

state set page state equals use state

86:44

i want to start with null because we don't have one yet we started with null when we made

86:49

the query so we've got that um and then i'm just gonna

86:54

we don't need that now once again i'm just gonna console.log the response body all right

87:02

just so we can see what is happening

87:12

oops response body okay so here we go here's our data the movie

87:18

genre page state so that is the next page state so you need to go data movies by genre page state

87:24

data movies by genre

87:32

page state so that is going to be our next page state um once again if like we refresh here

87:38

some of them have them some of them don't because some of them don't have more than six movies in the

87:44

section um that's fine okay so we have some for each of those sections

87:52

so once again i need to set page genre

88:03

and i'm literally just gonna get this so now i'm setting the page genre

88:10

if i console log the page state oops what i say that set page state

88:17

set page state so in fi console.log page state i should get the page state and what i

88:23

can do is essentially say

88:29

we've got our page state great and we want to get the next page

88:36

state if we click the button right so on the more button

88:42

on click oops i need to do that in the first tag um

88:50

and let's actually make this let's just leave it for now okay actually okay

88:56

on click well

89:03

if we click it i want to do a few things right i want to set the page

89:10

state again to

89:15

page stage so if i click it again i'm going to set

89:22

the page state

89:28

which is then going to set it here which is then going to send it on here

89:35

yeah so page state page state

89:40

okay so we've got a page state at the moment

89:46

we click it we want to set it up here so it sends it and then we want to fetch the data again

89:52

to get the next two okay so hopefully that makes sense

89:59

um this means that now in the get movies as well as getting the genre we're

90:05

getting a page state the body page state and

90:14

we need to put it here just like we were doing in the query remember we were just copy

90:21

pasting the next one next one that's exactly what we are doing here so

90:29

jason string if i

90:34

page state okay i'm just going to check it out

90:43

click great so we're getting the next six click well there's no more to get click

90:50

click click awesome

90:56

okay let's do the uh loading more genres first when we put our button here

91:02

i wanted to know the next four and the next four but not get rid of the others okay so it's not gonna be pagination we're

91:08

simply gonna be getting changing the limit this time so if you remember

91:13

this time let's go to our app.js and of course we are getting the genres

91:19

by passing through this query so i'm just going to show you in the playground again

91:25

query get all references i only want four so i can do it by writing options

91:33

if you want to refer to the docs that's fine uh i'm not going to or maybe i will

91:38

actually options just to be sure options limit so that is what

91:44

we want to use options limit let's save four so i only want four so now

91:51

and i want to actually update this limits before 8 12 and so on so let's actually just copy

91:58

that great so just like we did last time

92:05

we're gonna have to uh change this limit so back in our app.js file um

92:13

once again what i'm gonna do is actually const increment

92:21

uh count or just increment

92:30

genre increment is it an increment increment i'm just

92:35

going to save it as that anyway genre increment and let's say 4. and then

92:40

i'm actually going to so we've got this and then i'm going to create

92:47

another div here um so let's just check that to work

92:53

actually we should only get four so we're getting four now i'm going to create a div

92:58

at the end here so div uh give it the class name of page and for now

93:10

and then again in my styling

93:18

width is going to be 100 height is going to be i don't know 300

93:25

pixels i'm going to give it a background color blue so we can see what we are doing

93:35

so there we go now

93:40

no apps yes so now if

93:49

i'm gonna make this soft closing i'm gonna use on mouse enter this time

93:55

so on mouse enter um and once again

94:02

on mouse enter i want to uh set limit

94:10

so i'm going to use state again const limit set limit

94:17

and of course we we let's use use state inc genre increment

94:26

because obviously we know that as four on mouse enter we want to set limit to

94:32

whatever limit is plus the uh i guess in

94:37

general increment okay so we're going to set that um

94:46

let's just console.log limit for now see if it works

94:56

all right oops that's true let's put that up here

95:09

okay so each time i hover my mouse over s and d going up by four pretty

95:16

cool so now we need to actually apply it and send that over so let's again

95:24

um i'm gonna have to send that over as the body so method is going to be post

95:32

and then body go away body

95:39

this time i'm just going to send over the limit like this not the bossy body so i'm just going to

95:44

send that over to the get genres so event

95:50

and once again const we should call it limit equals json

95:58

parse event body so now that we have the limit i can

96:05

simply replace it here making sure to use json

96:10

stringify because as we know from before we need to do that otherwise it won't work

96:15

okay let's try so now

96:22

i've got four okay that's not working why is that not

96:28

working okay we are passing it through

96:36

and app.js passing it through

96:43

ah okay so

96:53

setting the limit we need to fetch the data every time limit changes

97:00

okay there we go ah we've done it okay so we've got eight now

97:07

i've got 12 now i've got 16 now i've got 20 now

97:15

and of course it's gonna keep incremented but we've run out of uh genres but that is pretty cool check it

97:21

out again uh that was maybe a bit too fast i think i've made this too big uh but we've got four we now have eight

97:30

we now have 12. we're now 16. we now have 20.

97:37

[Music] um cool well this is looking good and of

97:42

course if i click here we're getting more and more and we are getting uh we are looping

97:47

we are looping we're getting more and so on okay so we have now essentially done all

97:53

the heavy lifting of our app we have done pagination we've uh uh

97:58

figured out a way to load more and more genres on our page let's get to starting it up cool

98:18

okay so we've got our genres here um the first thing that i probably want to do is we're gonna have a navbar we're

98:27

gonna have this heroes section but just in here so actually let's maybe create that nav

98:35

bar

98:42

here section because i definitely know i want those two components there

98:48

so let's make them components nav rjs

98:55

and then again uh [Music] what was it here section

99:04

yes so const hero

99:10

section and then i'm just gonna return something

99:16

generic for now so return just nothing like so

99:26

and export default hero section okay so there we go there's one

99:33

on the nav bar and then i'm just gonna use command d to change this to left bar

99:41

like so and of course i'm going to import each one of those import import uh command d

99:49

heroes section and then command d

100:05

here section great so we've got those in there we then also have the genres

100:11

which are going to spin up a um let's actually put these in a container i think that'll probably make

100:18

the most sense so i'm going to just put div

100:23

class name container

100:31

i'm just going to whack that inside here

100:47

okay now inside this section i'm actually going to change this to an h2 tag

100:54

which i'm also going to give it an id of a genre because i want to actually be able to

101:00

navigate to each section if i wish by the header and then movie section call we

101:08

have also a more button um which i'm going to start again

101:15

more probably appropriately and then we have our card in which we have uh let's start

101:22

this up maybe a little bit more so we've got the video i'm gonna give the video the class name

101:30

of video 2 just like that and then

101:41

on the video itself

101:46

so yeah this is maybe not the source i want to put that on the video itself video class name video i'm also going to

101:54

put controls um so we can control the video and auto play

102:00

true so that it starts playing automatically um but we only want that if we hover

102:08

over it so maybe let's leave it for now and then let's make it loop again maybe

102:13

let's have that later on when we hover over it so that is everything we need let's maybe do some

102:21

styling now so as you can see each of them have controls now let's go to our css file

102:30

so the first thing we want to do is perhaps give our body the same color as netflix house so i'm

102:36

going to use background color i'm just going to make it like a really dark

102:42

color um that's quite a dark one and make sure that all the font is white so color white or if we want to

102:50

make everything consistent uh one two three it's fine we just need three

102:56

now font family um i'm just gonna use helvetica but please make

103:04

uh feel free to use like whatever you wish of course helvetica new i quite

103:10

like that one um so that is what i'm going to use

103:19

so now if we go look at the body at least that's looking a little better now let's actually style each container

103:25

okay um and i'm just going to give it a margin of 050 pixels

103:33

more gin

103:39

okay it's looking a little bit better margin um let's style the card more

103:47

a little bit so let's make the card with 230 pixels uh i'm going to give each of

103:55

them a border radius of 5 pixels too and let's say a margin

104:01

of 2 pixels just space them out a tiny bit

104:10

and then i'm also going to give them a transition so this is me actually making our cards

104:17

i guess expand transition transform 500

104:26

position relative display oops

104:34

display block cool so already that's looking

104:42

much nicer [Music]

104:47

now if i want to get rid of the controls on the video themselves what i can do let's give this

104:53

border radius to border radius 5 pixels

105:00

um i can do this i can get the video and i can use

105:07

media controls in order to not show uh the controls at all because we

105:14

had to put controls on the we just had to otherwise the the video wouldn't work

105:19

but we can actually hide the controls now using display none okay so as you can see the controls

105:26

are now gone now let's get to making the movies

105:33

actually stick out a little bit when we hover over them so i'm going to go into the movie section

105:41

and then uh when the movie section on focus

105:50

i'm gonna get the card so any card in the movie section and also we're gonna get the movie

105:56

section uh on hover

106:03

then we need to effect the card we want to transform the card so if

106:10

we're on focus of the movie section okay we want the card to

106:18

transform

106:24

translate minus 25 and then let's also give it a z

106:32

index of one so it sticks out

106:38

okay and then i'm also gonna add card

106:52

focus

107:01

so this is all stuff to essentially make um the movie cards

107:09

you know like stick out when you hover over them and so on transform translate

107:21

x 25 um so already you'll see they are

107:28

spacing out we just need them to get bigger now

107:34

and i could do that by grabbing the

107:41

movie section card focus

107:50

and then movie section we don't really have to i mean we're

107:55

only using the card in one place um so maybe some of this is overkill but

108:00

hey it's good too i guess just fool proof it right transform and this

108:07

is where we make it uh scale up by 1.5 so we're now increasing its size by 1.5 1.5

108:18

also giving it a z index of one so it sticks out so now you'll see the movie's

108:26

increasing in size they're great uh cool so this is looking good the next

108:32

thing i want to do is actually hide all this information and only show it on hover and also add in hero image and style the

108:39

button right so that is looking good um let's

108:44

actually change the more button i'm just simply going to

108:51

give it a height of 100 percent

108:58

uh display flex

109:10

give it some padding too i'm gonna put a icon in it okay so i already have an icon that i

109:16

use quite often and that's what i'm going to use today so i actually could just cut this

109:23

out and just do that um border radius

109:34

0 10 pixels 10 pixels zero cool so we've got our more button

109:41

and if we hover over the more button i think let's change its color so more button

109:49

hover let's make it ground color

109:57

um rgb two five five two five five two five five zero point five

110:08

great so now

110:16

oh there it is okay so we need to style this maybe a little bit further um let's do the more information thing

110:24

that i was talking about so back in the card i'm actually going to use state for this

110:30

as well so i'm going to import use stage

110:39

from react and then const is oops const

110:48

is shown or set is shown

110:55

so that's what i'm going to use to essentially figure out um if we're hovering if what what we

111:00

want to show on hover i'm going to set it to false use state is false at the beginning

111:07

from yeah you see from react okay now on the card

111:14

um once again on mouse enter

111:19

i just want to set is shown

111:27

as true but on mouse leave i want to set shown is shown as

111:35

false so it really is that easy on mouse leave and then i'm actually just going

111:41

to create two different components okay so let's get rid of this so that is the div

111:49

and i'm going to wrap this first one if is shown

111:56

then i want to show this

112:02

video okay so really simple just the thumbnail and then however if it's

112:10

not shown so if it's not meant to be shown actually no if it's not shown i

112:16

obviously want want to show the strip down but if it is shown so if i'm hovering over it well then i want

112:23

auto play to be true so i wanted to start playing and i also

112:30

want it to loop to keep looping the movie i also want to show an information box

112:38

so perhaps it's maybe put this in a wrapper

112:45

another wrapper just to finish that off um and then of course i i need to format

112:52

all of this but i will do that at the very end really okay so i'm gonna also have a div with

112:58

an information box oops let's say class name

113:10

info box we will call it okay

113:18

so there's our info box and when we hover over it well i'm just gonna

113:24

have the movie title um i'm not gonna have the synopsis you can

113:32

of course if you want i'm just gonna have the movie duration

113:37

uh two so that'll be in minutes uh let's just leave it let's just have

113:42

the movie title of course you are free to take this project and improve on it you have all the data

113:47

at your disposal you can even like have a click through where you see uh more information of the movie

113:53

if you wish so let's check that out okay cool so now if i hover over it i'm

113:59

seeing the title as well otherwise i don't see the title

114:05

yay so this is looking great and we have the button here of course

114:12

too um and i'm definitely going to have to do some more styling because

114:18

uh this i mean there's a lot of work to do so more button let's give it a height we

114:24

have given it a height of 100 okay let's carry on so now that we have

114:30

that let's actually uh style more stuff up so i'm also going to make a

114:38

hero section if you remember in here in my return well i just want to get one

114:45

movie really um i think i'm just gonna hard code one

114:52

movie so let's actually make a random movie i think that'll be more fun

114:57

so i'm just gonna use the get movies by genre query uh

115:06

or just the yeah the get movies query so where do we do that well we do it in the

115:13

section so i'm just going to once again just copy

115:19

all of this go to the hero section

115:25

and just paste it like so once again i'm making sure to import

115:32

use state and use effect from

115:40

react okay so this time we want to just get a let's

115:46

just say we want to get a random movie um it means that we don't actually need to pass through a genre

115:54

i'm just going to hard code her as sci-fi okay that is the movie that i

115:59

want to get uh we are going to again wait for the movie we're gonna set the

116:05

movie um we don't need this and in fact i'm just gonna get a random

116:12

movie from these so instead of just sending the movie here

116:17

i'm gonna get const movies

116:22

equals this and instead i'm going to get the movie's length and pass it through

116:30

sorry you use math random to multiply

116:38

the movie's length to get a random number that is anywhere between the

116:44

movies the array movies length and i'm going to wrap it in math floor to round it down so we get

116:51

a full integer okay so we're now getting a full integer and then i need to

116:56

get my movies array and pass through that random integer in order to get a random film

117:02

from our array okay i hope that makes sense um i think it should right

117:09

if it doesn't let me know and i could do an explainer but we are this is essentially just a random

117:15

number all of that is either a zero or a one or two or three depending on how many movies we have in

117:20

our movies array and i am passing that back through the movies array in these square brackets to get a random movie from our sci-fi

117:28

films okay so now if we get movie

117:35

set movie i'm going to call this set movie because you know we're just sending one equal

117:41

use state we're of course starting with null um

117:49

we don't really need page state here so maybe i'll just

117:55

constant page

118:04

state uh equals null let's see if that will well that

118:10

wouldn't really work if i was passing it through um you know i'm just gonna set

118:16

it anyway set page state even though this is sort of redundant i shouldn't really be doing

118:22

this uh okay

118:31

i think you don't know i'm just gonna set it as now whatever i'm sure this will work

118:38

okay great so we're getting around the movie

118:46

um yeah now

118:57

if the movie exists then we want to let's make this

119:05

class name of hero so we can style up the hero movie

119:10

and then in here um

119:16

once again what do we want to do here well i think

119:23

why is it done that video and then the video let's give this a

119:30

class name of um hero video so we can style it up

119:39

let's make it muted obviously we have to pass through controls and auto play true because the movie on

119:46

netflix does start auto playing so autoplay true

119:53

and again let's make it look and the source for this is going to be

120:02

well the movie

120:09

uh thumbnail okay and we just need to get a type

120:17

type video okay oops

120:25

should we have a look great so there's a random movie from sci-fi

120:30

there's another random movie from sci-fi another random move on sci-fi should we do action

120:38

let's change the genre action

120:44

there's a random movie there's a random movie and so on i prefer sci-fi though just

120:51

because i've actually um formatted them a bit better sci-fi

120:59

cool great now let's get some writing on top of it

121:06

um fun yeah let's do it

121:20

okay so we've got our video and under the

121:27

video so just here i'm going to make a div that we're going to hold

121:33

our uh you know the overlay of the information so info section i'm

121:39

gonna call it

121:46

and in it well i'm gonna have the uh let's call this hero blub

121:54

class name hero blurb and the hero

122:01

blurb is kind of the movie synopsis

122:08

okay so we're gonna have that and we're gonna have another div that i'm gonna call the class name

122:17

section and in the button section we are going to have a play button

122:25

plus name uh so it's gonna be a button but i'm

122:31

also gonna give it a class of play so that's two classes there and then a button with a class of more

122:40

okay like that so that's two class names and one two for the price of one

122:47

the play button i'm actually going to give it a span oops

122:54

because i want to use an icon in here um and the word play essentially

123:03

and it's the same for the more button so more will just have the word more

123:09

info like that cool

123:14

um so we need to obviously set uh start that up so it appears in here

123:21

shall we do that now uh i'm actually going to do the nav bar as well just put all the information we

123:26

need the navbar first before carrying on

123:31

the nav bar is going to be super easy that's why i wanted to do it i'm going to give this little class name

123:40

of bar like that

123:49

and in it i'm gonna have an unordered list with list items

123:57

so the first one is going to be the logo

124:06

the second one is going to be the home page

124:13

so it's going to have an href

124:19

i should probably use link but whatever

124:26

great so that's all we will need for the nav bar um let's finish our styling shall we so

124:32

we've got our container let's do our navbar

124:39

a height of let's say 50 pixels a width of 100

124:46

percent position sticky because we always want

124:52

it to be at the top and top zero

125:03

next let's do the hero section so the hero section again i want to have

125:08

width 100 let's give it a margin

125:16

top of minus 100 pixels

125:24

and then i'm just gonna give it padding zero like that so that's what it should

125:31

look like now

125:43

and now let's start the info section it's going to go over the hero image so dot info section

125:55

position i'm gonna have to give it a position absolute and then

126:01

margin top uh i'm just going to put 30 percent

126:10

of whatever the parent

126:15

is margin

126:20

um let's put 50 pixels from it and the parents left

126:27

and give it an overall width of i don't know 600 pixels let's say

126:32

so now

126:45

got the movie section let's make the button section

126:56

display flex uh and the button so anything with the

127:02

class of button there was two buttons to each shared uh this class i'm gonna

127:07

give it a border radius

127:12

10 pixels um a background color of

127:20

one two three just for now uh let's make the um writing black

127:28

uh and it's got a padding of uh 10 at the top and 20 at the sides and 10 at the bottom and

127:35

margin of 3 pixels

127:42

now if it's a play button um well yeah let's keep the background

127:48

color white but if it's a more info button

127:56

i want it to give it a background color that is slightly different

128:06

so this is the color that we got from i lifted this from the

128:12

site itself it's like a transparent color essentially

128:36

so now in the hero section if it's got a more oh it's just more is it okay more

128:50

and it's going to look like that okay great so we've done that um

128:58

we have our card we have our videos we have our hero video

129:05

so let's do our hero video

129:14

dot hero and this could explain why

129:20

with 100 float

129:28

left top zero padding none

129:38

i forgot about the hero video okay so now that looks better and

129:43

actually if um this would make sense to make it

129:48

around 30 percent and then i actually want to move the

129:53

here section so margin top 100 pixels so i want it to be all

130:01

the way up because i want the nav bar to go over it okay now let's do the navbar right so

130:08

let's get the unordered list um let's just give it display

130:16

flex list style i'm going to say

130:23

none and then let's get the list item so each

130:28

list item um well i'm just going to give it maybe like a little bit of margin okay so none from the top and 10 pixels

130:36

from the side and none at the bottom that's the shorthand for writing that so now

130:42

okay that looks a lot better and then we just need a title so the logo sorry so i can do that easily

130:53

i'm just gonna actually get the info box itself so where's the info box

131:02

we're going to style the info box we haven't styled the info box so let's do that maybe now um so the

131:09

info box is basically what stores the information for the movie title when we hover over a

131:15

movie card and

131:22

well well i want this to perhaps be a hundred percent uh let's give it a padding though of 10

131:29

pixels um and then a background color that's the same as the background color

131:35

of the page just in case there's like a movie or something under it and i'm also going to give it a box

131:41

shadow so i've just literally taken that from

131:47

the internet it's not even being applied where's the card

131:53

info box okay so it's not even being applied there we go info box okay so now you can

132:00

see a little bit more of a i'm a box shadow but please like i said

132:07

feel free to mess around with these if you wish

132:17

okay so that's a lot darker i think i prefer that one it also needs a z index so let's give it

132:23

a z index to make sure that it's always i guess in front of everything said

132:29

index five because i think we've got a lot of z indexes one now

132:35

and finally let's add the logo and the icons so i'm going to do this in the public

132:41

directory in the index.html file under the meta i'm just going to stick my script for front awesome

132:47

please feel free to get your own font awesome is amazing you can have so many icons

132:52

so this is what it looks like you just need to sign up and it is for free um

132:59

i already have my icons that i want to take so i've got a play icon

133:06

so i'm going to use this one right here and all i need to do is start using this

133:12

icon and simply copy this like so and then in the uh let's go into the

133:20

main section so the hero section i'm simply just going to paste it here and change this to be class name

133:30

so so now there we go we got a little icon uh

133:36

that is pretty fun um you can of course add way more icons i'm gonna do that too i think i'm gonna

133:44

have a more info icon so

133:49

more info

133:54

oops we'll just put info

134:01

and i quite like that one so that's the one i'm going to use uh start using this icon copy this once

134:08

again and just stick it in my project it really is that easy

134:16

uh so once again there we go again like please feel free to style

134:22

these out a bit i will uh let's grab it by this

134:28

once again i'm just going to go here and um

134:36

right here probably just there i'm going to give it a margin nothing from the top maybe like

134:44

three pixels from each side uh and nothing from the bottom i think

134:49

that should be fine you can even do a little bit more i

134:54

reckon maybe like five

135:01

cool and i think that's looking better and let's just get rid of the uh styling

135:09

so a um we need to put text decoration

135:15

none and let's just make it white

135:22

like so so now here i am going to once again get the logo and i'm going to use

135:30

background image i'm going to use the url of now with our logo i've actually

135:37

saved it again to my imager just to keep everything in one place really so if i go here i'm

135:44

just gonna copy the link here and then paste it like so okay so there we have it uh i'm also

135:51

gonna put background size uh 88 pixels

135:58

let's give it some margin because i love giving things margin and of course maybe let's set its width

136:04

to 88 pixels too so there we go

136:10

uh we also have to give it a height of course width height

136:17

22 punch

136:30

let's just carry on styling this for now so we've got the info section

136:44

um

136:50

i will leave that for now

137:24

okay and there we have it we have finished our netflix clone i mean it looks

137:31

great please feel free to style this much more than i have i didn't want this to be all about the

137:36

styling i wanted you to be able to you know be able to create a project using data stacks using graphql

137:43

learn how to do pagination learn how to you know set new limits and pass them through into

137:48

your graphql queries so i hope you have learned that please

137:54

do take these projects apply this knowledge that you have learnt in this video to

137:59

anything really that you wish that is totally up to you i would absolutely love if you can share the final thing

138:05

with me um please share your netflix clones or please show me what you have built

138:10

using this knowledge as well i would absolutely love to see thanks so much again for coding with me

138:16

and i hope to see you soon okay everyone thanks again and bye

No comments:

Post a Comment