⭐ 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

Tuesday, November 11, 2025

Learn GraphCMS and GraphQL by building a Next.js Disney+ Clone

 Learn how to use GraphQL and GraphCMS by building a Next.js Disney+ Clone! In this 2hr tutorial I show you how to use a Headless CMS in order to build a working streaming app. You must sign up here to follow along with the tutorial: https://go.graphcms.com/

0:00

hello everyone so I'm super excited for this we're going to learn how to build a Disney clone using

0:06

a Content management system but not just any content management system one that is based on graphql

0:13

okay so a lot to learn in this video we're going to learn how to create schemas and models and then we're going

0:20

to use that in order to upload data such as MP4 files and jpo files and strings

0:25

onto our content management system and then we're going to learn how to retrieve that data back using queries

0:32

and mutations okay so queries retrieve all data and mutations to edit delete

0:39

and create a new data too okay so this is what the finished product will look like by the end as you

0:46

can see there is a page like a home page where you can view all the videos based on category and if you click through

0:52

into a card you will see the individual item and if you click play a video will

0:58

appear there's a lot happening behind the scenes there is a mutation happening here but don't worry we will cover that

1:04

as we go wonderful now the only prerequisites that I asked of you before starting this

1:11

course is to have a basic understanding of JavaScript HTML CSS and react and

1:16

whilst next year s is nice it is not necessary for this video so it is going

1:22

to be a long one but loads to learn so I hope you're super excited I can't wait to get going let's get to it as always

1:28

please do give me that sub if you do like my channel as this really is the way this channel can grow and I can

1:34

continue to create free content for everyone here okay so let's get to it the first thing

1:41

I do is obviously just log in to my graph CMS now I've already signed in but

1:48

if you haven't used this before then please do take the time to sign up just post here and do so until you see this

1:56

dashboard right here so now the first thing I'm going to do is just create a new project I'm going

2:02

to start off with a blank project as I want to be doing this completely from scratch of course if you ever want to

2:09

come back here there are plenty of templates for you to make your life easier too

2:14

so I'm just going to click here and what shall we call this I'm going to call this

2:20

Disney plan a clone of Disney

2:27

for educational purposes just in case I get sued for educational purposes

2:35

great and I'm just going to click Europe because that is where I am

2:41

and create a project so that should get my project set up in

2:49

order for me to start working on my schema okay first off I'm just gonna select

2:57

free forever so I'm just going to select that plan

3:02

and I'm going to select invite later okay great so here we are on the dashboard I mean I

3:10

know what to do the first thing we're going to do is set up some schema the next thing we're going to do is create some content and then we're going to

3:16

make our API accessible so that we can use it in our project so let's go ahead and do that we will be

3:23

using the interactive playground as well I'm going to show you how to do that so we're going to cover all these four points essentially

3:29

so just in here here is the first thing we're going to do is going to create some schema

3:35

now the schema that I want to make I think the first thing we should make is the video as that's the first thing we

3:40

need to create really so I'm just going to go ahead and create a model and I'm just going to call it a video like so

3:47

I'm gonna let these Auto populate because I'm happy with that this is looking great plural of videos videos

3:54

and the API ID that looks good to me too we can put a description but I'm not

4:00

going to for now if you are using this in teams then perhaps that is wise as it does make your work more readable to

4:05

everyone else and just create

4:11

okay so now that we are here perhaps this click don't show again all I'm

4:17

going to do is create my video model so what do we want our video to have well I

4:23

wanted to have a title so that is going to be a single line text I'm going to put title uh

4:32

again description I don't really want this and do we want to allow multiple

4:38

values no we don't want any of that and then we can also put make this field required okay so that we have to put a

4:45

title in for our video so that's just what I'm going to select and this looks good and I'm just going to click create

4:51

okay so I'm going to do this first and then we'll talk through a little bit so I've just added a title to my video

4:58

model the next thing I want to do is put a description so maybe let's make this a

5:03

multi-line text let's call this description and then shall we make this required

5:10

let's make a required so I'm saying that anytime I want to create a video in my

5:16

uh I guess content manager it has a title and I

5:22

have to put in a description I also have to put in an mp4 file right because that is the main Crux of a video so I'm

5:29

actually going to go to asset picker and let's call this an mp4 and then let's

5:34

also make this a required field and just click create

5:42

so this is looking good now what else do I want I can also have a Boolean so I

5:48

can actually select a Boolean of if this video has been seen or not so I'm just

5:54

going to put a scene and this does not need to be required I'm just going to put those optional

6:04

and the next thing we need to do is have a slug for those of you who don't know what a slug is a slug is simply a uh way

6:12

a URL identifier okay so that if we visit the slug that we will visit the video itself so let's call this slug

6:21

like so and again I'm going to make it required and it's already set as unique

6:26

that is good and wonderful I'm not sure if we do need to

6:34

do anything else here we've got the display name we've got this we can also

6:41

have generate slug from template let's just have that and let's generate this slug based on the title okay that we

6:49

give the video so that is the Syntax for doing that I can of course generate this by whatever I wish I'm choosing to

6:55

generate it by the title and it's going to be lower case

7:01

okay and this is looking good and create

7:10

great I need to do two more things so I also want to add a thumbnail so that is

7:16

going to be an image so once again I'm just going to select the asset picker and I'm going to make it a thumbnail

7:22

like so spinning thumbnail correctly and I am going to say

7:28

that this is not required and I'm just going to create and the last thing I want to do is

7:34

actually add some tags to this too so I'm just going to select this so I can

7:39

essentially put tags to the video so that you know like on uh Disney plus you probably have a video that belongs to

7:47

family comedy and so on so that's exactly what I want to do let's call this tags making sure that it's capital

7:54

and this time well I want to allow this to have multiple values so I'm just

8:01

going to select this and create okay great so that is our video model

8:10

wonderful okay so our video model is going to have a title description MP4 we're going to allow it to be seen or

8:17

not seen it's also going to generate a slug for US based on the title and then we're also going to request a thumbnail

8:24

to add it to the video and some tags wonderful okay we have to actually reference this

8:31

but I think let's continue first because that is something I'm going to do last I essentially want to reference it to a

8:37

specific user or platform but let's get to creating the usual platform first so

8:43

we've got the video the next thing I want to do is

8:50

create a unique platform okay so just imagine that each platform has its

8:56

specific ID because you want to know exactly what videos have been seen on that platform so say it's the Smith's

9:02

family's platform they're going to watch some videos if it's someone else's platform they're going to watch some different videos and so on so let's go

9:10

ahead and do that so once again I'm creating a new model so we've got a video model and our platform model I'm

9:17

just gonna click that like so okay and what do we want in our platform

9:24

model well we could have a title sure let's give it a title just so we

9:31

can sort of identify you know as the Smith's families or so on and let's make this required

9:38

so make required field I'm also going to generate a slug for it so once again a

9:46

slug the display name is going to be a slug

9:51

and then again let's make this required but also setfield is unique and great

9:57

let's go ahead and create that

10:03

and one last thing each platform is going to consist of multiple videos however I want to reference this video

10:10

okay I don't want it to be the video itself I want to reference the video so

10:15

to make a reference I'm just going to show you how to do that I'm just going to click and click here sorry and I'm

10:22

going to say that I want to define the relationship allow multiple models to be

10:28

referenced so this one right here and I'm going to the model I want to reference is the video model so just

10:36

like so it's going to be a two-way reference with one two

10:42

many like so

10:48

okay great so one to many that looks good

10:53

allow multiple videos per platform but don't allow multiple platforms per video

10:58

okay so that makes sense one platform uh has multiple videos not the other way

11:04

around and finally okay so this is good let's continue

11:12

let's give it a display now so I'm just going to call this video reference like

11:17

so and give it the API ID of video reference

11:25

and wonderful that we're going to leave as it is and click create

11:32

okay great so this is looking good we've got the platform we have the video the last

11:38

thing I'm going to do is just create accounts so let's go ahead and do this again I'm going to call I'm going to

11:45

create a model for an account just like so and click create model

11:55

and what would we like our account models look like well I want it to have a username so that each account has a

12:02

username which is going to be a required field to make required and that's about

12:08

it the next thing that I'm going to do is run an avatar because each account comes with this little picture so let's

12:15

call this Avatar just like so and okay this is looking good do we want allow

12:21

multiple presence no so let's just create that okay so there we go and one last thing each

12:28

account is of course going to be linked with you guessed a platform

12:34

so let's do that we want the model to reference platform and it's going to be a one-way reference one two one

12:41

and we don't want to allow multiple platforms per account we just want it as

12:47

it is so it's going to be a one-to-one relationship and continue create

12:53

wonderful okay so I think that is all we need to get started in putting our data

13:00

and assets into this platform Okay so we've created our models we've defined

13:07

the relationships between the models now let's get to using what we have built so

13:13

let's get to it so we've completed this part the schema let's move down content

13:19

wonderful okay so now that we have done that I'm

13:27

just going to create my first item so let's make this a video I'm just going to select here and ta-da so everything

13:35

that we created in the first part so in the schema part you will see I'm being asked for a title which is required a

13:43

description which is required and then before file which is required the booleant associated with an account or a

13:50

platform and then to create a slug which is auto-generated and add some tags as

13:56

well as a thumbnail that is crazy I've literally just built this and it's in front of my face I'm being asked to put

14:01

this data and only this data nothing else so let's do it what should we call my first film let's

14:08

call it Jaws a film about a shark

14:17

let's maybe make a little bit longer just real so we have something to work with a thumb bat shark uh this is a

14:25

classic film that is pretty scary at times

14:34

and just great in other times okay

14:40

I mean I'm not I'm not a copywriter don't hire me as a copywriter clearly

14:46

Okay so we've got a title a description let's add an existing MP4 so I'm just

14:52

going to actually upload the trailer because I don't want to be here forever so all I'm going to do is drag it in

14:58

from my downloads I'm probably going to speed this up

15:04

because you don't really want to watch this so boom

15:12

great and now seeing I'm actually going to just leave it I'm not going to leave it true or false I'm just going to leave

15:18

it as null the slug has been generated from the title for me as we requested

15:23

and I'm just going to add a thumbnail so I'm just going to upload a thumbnail for

15:29

this one that I have also just downloaded

15:34

and just click upload okay so there we go and tags what we're going to put I'm

15:40

gonna put classic what else can we do we can put Thriller

15:46

I'm not sure this is a Disney's one but just bear with me I'm sure it's fine let's also is it family it's not really

15:53

family is it let's put scary or let's put uh drama

16:02

and let's put animals

16:08

okay I'm just gonna try to do four for each again probably shouldn't work at Disney plus because these tags don't

16:14

really make sense but I'm liking them anyway okay so hopefully you get the gist okay and then once we have

16:21

everything we can we also do need to link this to a platform we don't have one yet so I can actually choose to

16:28

create a new platform from here so let's go ahead and do that let's call this

16:33

platform Smith's family so it's whatever they chose to

16:39

call this platform when they signed up to Disney and then let's generate a slug perhaps let's make it random this time

16:47

let's go ahead and just make it quite random so this is something that

16:52

let's say we just generated okay and

16:58

wonderful so this is looking good and then of course

17:05

um we would have to add video references so this is essentially saying which videos the family Can See For example

17:12

maybe they're in a different region like Europe that's different to America and I know that Netflix doesn't allow certain

17:18

videos on certain networks so so we would then have to add an existing document but we haven't published this

17:24

one yet so I'm just going to save and publish this everything that we've made so far

17:30

and great so now our video is published and

17:35

if we go to platforms oops now we need to publish this too so we just published the platform now we need to publish this

17:44

and let's publish all of these as well so everything is now published great and if we go into

17:51

the platform let's edit the platform and wonderful so we have a video that is

17:57

referenced to as well okay and if we edit it you will see it's Jaws great

18:04

wonderful and now let's just create an account so I'm going to create an account my username for the Smith family

18:11

for some reason I'm called Anya Smith so maybe let's do that Ania Smith oh one that's the username and then it's

18:18

given me an avatar so I'm just going to upload an image of myself

18:24

there we go and upload great so username and a headshot and

18:30

which platform do I want to associate myself with well I want to associate myself with the Smith family so let's go

18:38

ahead and do that and save and publish great okay so Anya Smith part of the

18:46

Smith family can see jaws okay because that is what we have done we've linked all this up Jaws is available on the

18:54

Smith family platform that I as Anya Smith have access to wonderful

19:00

so ideally we would have a lot of data here however I don't want this to be all about data uploading

19:06

um so I'm gonna upload four videos just to get to the coding part and then at the end I'll show you what the platform

19:13

looks like with a bunch of other data but like I said I don't want you to sit here while I just upload uh you know

19:19

dozens of videos so let's just do four Mulan a Disney

19:25

classic in which uh girl or young woman goes to fight for

19:33

China okay

19:40

now um once again let's add this to an existing platform so the

19:46

Smith family platform they can watch Mulan let's put an existing MP4 so I'm going

19:51

to upload one two here of the Mulan

19:58

trailer once again

20:09

great so we've got the MP4 trailer c not seen I'm gonna leave that as blank the slug has been generated for me from the

20:17

title so it's really good or lowercase and let's add a thumbnail so once again I'm simply going to drag that in from my

20:23

downloads and then Tags I'm going to put classic

20:29

here I do think it's a classic I'm also going to put family

20:35

I'm also going to put drama and I'm also going to put Disney because that is a Disney classic

20:41

so I'm gonna put Disney in there too okay great and save and publish let me just

20:48

check that we've done all of this okay tip and publish

20:53

select all save and publish correct okay two two more that we're going to

21:01

make publish

21:10

create item this time Moana is story

21:17

don't really know the story very well of a young girl who meets a demi

21:27

what and saves the

21:33

world okay I'm not sure if you saved the world but you know what I uh I just needed

21:40

something she saved something okay add an existing platform once again the Smith family platform's gonna be linked

21:46

to this they can watch Moana existing MP4

21:51

let's upload Moana official trailer so there we go and once again I'm gonna speed this up

22:03

great and add an existing thumbnail

22:08

so I'm just going to select that one that looks good and tags once again let's put family

22:13

this is a Disney film so once again I'm going to put Disney it's not like Marvel or anything

22:21

Star Wars uh let's also put what can we put here we need some more tags comedy

22:31

and let's also have what's your nose because it's quite hard

22:37

to think of these it's not really a drama Adventure

22:43

great so we have all of these filled in and we're dissociated with a platform great

22:51

save and publish select or save and publish okay wonderful one last one I promise uh

22:59

Four's really not enough but you'll get the gist of what we are doing so eternals we're gonna have a Marvel one I

23:06

don't really know what this is about either I just saw it when I was Googling a Marvel film

23:13

with I think it's Angelina Jolie so I'm going to put that calming

23:22

um this is a great film everyone should

23:28

see it immediately I mean no one Cena I think it's it's not

23:33

really even out yet okay

23:40

great so we have that once again at an existing platform The Smith's family can

23:45

see this you could replace the Smiths with like Europe or something you know and then have a Associated account with

23:52

Europe that have users if you want if you want to add in that extra layer if you really are as big as Disney uh but

23:59

this is just to give you an example of what you can do add an existing MP4 okay so I'm just

24:07

gonna upload and just upload that MP4

24:17

okay great and I think we're nearly done once again let's generate a slug and an

24:23

existing thumbnail so I'm just going to upload one again very last one now

24:29

so just there we go upload

24:34

and the tags we're gonna have for this well this is Marvel and then it's also our family I'm gonna

24:41

have Adventure again and let's maybe have

24:47

action um or let's put Thriller Just because I

24:54

want to have multiple tags okay so save and publish and we are done let's carry

25:01

on great so we have created our schema we've then done the content Parts we've

25:08

used our content manager to upload assets and data you know MP4 files and

25:13

jpegs and next we can actually see all the assets that we have so there we go you can see all

25:20

the images and the MP4s this is looking cool and then let's have a play around

25:26

in our API playground to see if our data actually comes back to us now for those of you who are the familiar with graphql

25:34

I'm going to show you how it works in a very crash course sort of way so let's

25:39

do it so to us dispersal we actually have the docs so this has been generated based on

25:46

the schema we wrote okay this is really clever so if you look here well you will recognize videos okay and

25:55

each video so we can query for all the videos so if you look here let's just go

26:00

a step back actually here is what I can do I can query for things so in other words I can search

26:06

for things in my data using the query word here or I can add stuff or edit

26:13

stuff or delete stuff using the mutation so I'm going to choose to query and this

26:19

is really helpful these docs have been essentially generated for us so if I want to query for videos I'm simply

26:24

going to write query open up some curly braces and if I want to search for videos

26:30

okay if I want to search for all the videos I can do so just like this and

26:36

then if I search for all the videos well what do I want to come back I want a video to come back and this video is

26:43

made up of we can have an idea you can also choose for these extra

26:48

things to come back so obviously we added the title

26:53

we also added a description we also added scene we also added a slug and we

27:00

also added tags but look at all the stuff we didn't add so created by updated by published thumbnail we did

27:07

add um so let's have a thumbnail thumbnail actually is part of an asset so these

27:14

okay let's go back to step one again so I didn't add an ID but this one's been generated for me which has the type of

27:21

ID we added a title which was a string we did choose for that to be a string same as the description a string scene

27:28

was a Boolean that's right slug was a string again a required string hence the uh I guess what's it called exclamation

27:36

point and the title strings in an array so that's also defined for us that's what's going to come back but all these

27:43

extra things such as created that updated that's that's extra stuff that we can get so

27:49

I'm just gonna go for it let's get created at let's see what that returns and then also a thumbnail now a

27:56

thumbnail is actually an asset okay because we did choose an asset and the asset comes with all of this as well so

28:03

I could just get the file name I could also get a height and width of the asset which is quite cool and then I can also

28:13

get the URL so that is one of the things I wanted so now if I run this

28:19

this is what returns so here is my data here are all the videos let's have a

28:26

look at the first object in here so that is one object you will see that the film

28:31

Jaws or the video draw as well that gave me the timestamp that I created this it also generated an ID for me so I can

28:38

pick it out there's the title I gave it there's the description I gave it we didn't set scene so that is null is this

28:45

slug that got generated for us the tags as an array of strings and the thumbnail URL so that I can get the thumbnail

28:53

wonderful and of course we have four of these objects because we made four videos

28:58

so that is how you would use a query to return all the data that we have okay so

29:06

maybe let's save this query we can of course like I said get more we can get the size of the thumb we can get all of

29:12

that one thing we did forget is to get the MP4 actually and what does the MP4 come with let's

29:18

see let's go back

29:27

as the MP4 it's an asset that comes with once again I think I just want the URL

29:36

yeah let's just grab the URL so there we go so this is what I want to

29:43

save let's save this query um

29:50

okay so here we go those are my queries and then let's make a new query so once

29:56

again query and this time I just want one video so let's go back to here let's

30:02

look at queries and I just want one video so here we go

30:07

video so now I need to open up these and I need to put where and for where

30:16

I need to get the unique identifier video so if I want let's just say I want the eternals

30:22

eternals have this ID so I'm going to grab that string I'm going to paste it

30:27

here okay and then what do I want to return well I can also do it by slug by

30:34

the way I didn't have to do ID that's what the documentation told me and then

30:46

foreign what do I want to return well I can

30:51

actually just return the same things so if I look at this query and I just take all of these

30:58

and whack them in here and run this

31:05

Oops why is that wrong uh okay we wrote this incorrectly where

31:13

I'm going to open up some curly braces and ID you have to give the ID like so

31:24

and now run it okay and there we go what is returned back to us is just the one video the

31:32

eternals video with all the information that we requested so all of this okay and I can also do it by slug

31:40

which is probably a lot more memorable so Slug and then I'm just going to put the string of

31:47

eternals a video not eternals how did I spell it

31:53

slug and see what this slug is for tunnels

32:03

tunnels

32:08

and there we go wonderful so we have created some schema we've

32:17

added content based on the schema we defined we have then had a look at all the assets and then we've played around

32:24

in the playground to check if our queries work and we've saved our queries so we can use them when we start

32:30

building our project so now I think this time start building our project let's do it

32:37

okay so to do this I am going to make a next JS app

32:45

so to do this I'm just going to get up my terminal I'm going to go into webstorm projects

32:51

and I'm just going to use the next command which is next.js

33:00

next to us create app just making sure I get the right command

33:06

because I can never remember it

33:12

okay this one right here npx create next app and let's call this

33:19

Disney clone and just click enter

33:25

okay so that is now at work it's going to essentially return back with a project that's been configured for us

33:31

with a template as well oops we need to install the Lotus so

33:37

let's just go ahead and do that

33:54

okay great so now let's get up webstorm or whatever code editor or ID you are

34:02

using it's going to get it up

34:13

I'm just going to open the Disney clown project

34:21

okay wonderful

34:27

okay so this is the command that I need to start this

34:33

I'm going to copy that go to that get the terminal and just

34:39

use npm run Dev and now I'm going to visit here

34:52

and wonderful so this is the boilerplate that it comes with I don't really like it we can obviously get rid of all of

34:59

this uh perhaps let's do that okay I'm just going to keep this running down here and actually no let's just make it

35:06

smaller we don't need it now so now it comes with a bunch of stuff a bunch of

35:11

stuff that I don't really want so let's go ahead and delete it in the pages in the index.js file I'm just going to get

35:17

rid of all of this so I'm literally just going to get all of this and delete it

35:26

okay so now we just have one div let's put hello to see if this has worked but

35:31

I'm pretty sure what it has and now we don't need any of these for now even though we might need the next image

35:37

later on so I'm just going to delete all of this

35:44

okay so that is now gone in the app.js file

35:51

the only file I want to keep for styling is this one we're not going to have that much styling so I think that's enough

35:56

and I'm just going to delete this file right here

36:01

okay so just the one style sheet now and we don't really need these either so I'm

36:06

going to delete this uh let's keep the fabric on why not so in here we've got a

36:12

fresh start and in here we've got a fresh start too um I'm just going to rename this just

36:18

because this is I prefer functional expressions okay so that is looking good and

36:25

index.js oops oh so we need to export default my

36:30

app okay and just in here too so I'm just

36:38

gonna once again change this to a functional expression so const

36:45

um equals it's just my preference you could have

36:50

kept it as it is export default wonderful

36:57

okay so now there we go we see the word hello I'm

37:03

just going to inspect this so we can see a little bit better what is going on

37:10

okay so now that we have done that I think the first thing we should do is

37:16

worry about getting our data and see if our data is coming in here correctly before we do anything else so let's do

37:21

that okay so the first thing I'm gonna do is

37:26

uh get the data so I'm going to do this like so the first thing that we need is

37:33

actually well because I will be making graphql queries I need to import the gql

37:39

tag to allow us to write in a subject like gql language and format and the

37:44

graph ql client

37:51

from a package called graph request

37:57

I can only spell things correctly request okay graphql request sorry that's the

38:04

correct package and this is what it looks like

38:19

so this is what we need okay and it comes with a bunch of really useful things if you want to have a look

38:25

at it then please do essentially we are going to be using this syntax to request

38:31

our data and pass through queries into as well so let's do it let's go ahead and

38:38

install this package so we can use it so let's get our terminal up I'm just going

38:43

to make a new a tab and do npm eye for install graphql

38:52

request okay so there we go that's installing I'm pretty sure that's the

38:57

only package we need but we'll see okay so now that we've done that I need to

39:04

this is the Syntax for getting static props we're going to get static props we're not going to get server-side props

39:10

uh so get static props

39:19

equals maybe let's make this bigger I don't know if you can read it get status products equals and this is going to be

39:24

an async function um right so to make a essentially if I

39:33

want to get this data right here well I would need to visit this URL and I'd also need a

39:40

token okay so because we are in here and

39:45

this essentially we don't need a token for this because we're signed in if I was just to visit this URL without a

39:52

token it wouldn't let me access this data okay so let's get a token so all I'm going to do is go to settings

40:02

I need to create a token so I'm just going to

40:08

click here and what should we call this Ania Dev token of course please feel

40:14

free to call this whatever you wish uh and then yes publish so create like so

40:19

okay

40:25

tunnels

40:30

and there we go wonderful

40:36

so now that we have that and I have access to the published stuff it's going

40:43

to create copy this because that is a token that we need and I am just going to

40:51

save it so for now I'm actually just going to put it as a

40:57

string here we should really save this to a NV file but let's just check it works here first of course I will be

41:03

deleting this so please don't go ahead and use it it won't work by the time I publish this

41:08

so exporting get okay and then I'm going to use the graphql client so

41:16

this is how you would use it I've just gotten this from the documentation of graphql request the npm page that I

41:22

showed you new graphql client like so and I'm just

41:28

going to pass in so we're going to pass a URL as well as a header so we can communicate with

41:35

um our data so headers I'm going to pass through the header

41:42

and this is our token I'm just going to cut that and whack it in here of course it's just

41:49

try to keep everything consistent okay so maybe let's make this a little bit smaller so you can see

41:58

well it's a long token okay so I've got a graphql client uh by

42:06

making a new graphql client so I've imported graphql client from graphql requests I made a new one and I thought it's worth your client I made a new one

42:12

by passing in a URL and some headers so you can communicate with that database and as I said this is the URL that we

42:21

need to communicate with our database so let's go back to here this is it so I'm

42:27

going to grab that if you need this with a header so we can communicate with our

42:32

database so let's save that as well hopefully you see

42:38

how this works so let's save this as const URL equals

42:44

once again just makeup string okay why am I getting curly braces

42:53

oh whoops okay okay great

42:59

so now we should be able to communicate with our database but let's try it out

43:04

so what's the query we were making well const let's just call it query for now

43:11

so I'm going to use the gql tag so I can literally use the Syntax for queries however we want

43:19

to get all the videos don't we so I'm going to use this I'm just going to copy that that we made I'm just going to

43:25

paste it in here okay so all I've done okay so there we go if you want to

43:33

format it a little bit better then please do I will be doing this all later I don't want to focus on it too much for

43:39

now but there we have it so that is our query

43:47

making sure that this is all inside get static props Okay so

43:55

why is this not closed off okay so here is get static props and inside

44:03

we are creating new graphql token where we're passing through the URL and the

44:09

header so we can communicate with our database great our saving it as graphql

44:15

client and then we also have a query okay so that is good we've got a query the next thing we need to do is uh

44:22

actually get our data so we get our data so I'm going to save it as let's save it as just data for now

44:29

and then I'm going to use await graphql client

44:40

let's make this a small G just to differentiate a way to graphql client

44:46

requests so this is exactly what I showed you here this core way of requesting

44:54

data okay I'm gonna pause through a URL pass

45:01

through a query and then get our data

45:08

okay request and then I'm actually going to pass through

45:14

query because we don't need to do any of this other stuff because we've sort of already done it there

45:20

so just request the query like so so we're going to get these data and then once the data comes back to us

45:28

um well actually maybe let's just console log data see what comes back to see if

45:35

it works

45:43

huh

45:53

module not found okay wouldn't be let's stop this from running and just install

46:00

all the packages again

46:09

okay and just on the project

46:36

ah okay it's strange this apparently solves the issue let's try it out

46:48

okay once again

46:53

see if that's worked npm install and Save graphql as a dependency

47:02

okay great so this is looking good we did not add a return so let's go ahead and do that I thought it could just work

47:09

with me consoling the data but it won't let's return some data well perhaps

47:14

let's just try without any of this hard stuff let's just take let's just see if it works on these so closing tag

47:21

closing tag so all I'm going to do

47:27

is return and let's return props

47:33

okay so I want to return the videos um and I think

47:40

okay let's have a look at the response here

47:46

so if I make this query this will return data

47:51

and that has videos so I undergo data videos so let's just try that

47:59

const videos equals data dot videos so it's gonna return an array of videos and

48:07

then let's just console log out videos so we can see what is being returned so

48:12

if I then pass through videos I'm going to de-structure videos like so and go console log

48:19

videos I should get all the videos coming back to me so let's check it out

48:26

and great okay so we have all four of the videos

48:32

this is looking good I'm just going to replace my full query again so we can

48:38

get all the data so just here I'm just going to replace it back to what it was and have it out

48:45

okay so this is now working brilliantly we're getting our data so

48:53

now that's worked I'm actually I'm going to put this in a DOT EMV file I think it's always good to check in here first so just in the root of my project I'm

49:00

going to create a new file called dot Envy

49:08

and then I'm just going to grab my token

49:14

and what shall we call this maybe let's call it uh graph

49:22

CMS token

49:27

and then I'm just going to save it

49:39

and then also we need the end point so let's just save this as endpoint and

49:44

then let's grab the end point

49:51

put it in our EMV file and then let's replace it in the index file so to

49:56

access this I need to write process EnV that's how we access EnV variables and

50:02

I'm going to put endpoint exactly how I spelled it in the EnV file and then the same

50:09

for this process EnV and what do we call this oh yes that was it graphs you must took and

50:16

a thank you webstorm okay so hopefully that should work and we

50:21

didn't break anything let's rerun this

50:27

we need to inject the variables

50:35

okay and there we go everything is fine let's carry on so we're getting the data

50:42

we're getting all the data that we need for our uh I guess home page the next

50:49

thing I want to do is create a individual page so this is how you would do so in next.js I'm actually going to

50:56

create a folder um let's make it on the same level as API

51:05

so pages in Pages yeah that's correct okay and then I'm going to make

51:13

a new directory called video

51:19

and then I'm going to create a new file and then it's just going to say slug

51:25

dot Js so just like so add okay so in here we're essentially going

51:33

to build a another query we're going to write another query but this time to get one

51:41

fill based on the slug okay so that is what we need uh let's

51:47

actually just put some boilerplate in here so all I'm going to do is what should we call this let's

51:53

uh call it comes to video

52:05

export default video just like so and then just let's

52:11

return for now let's just return his div it really doesn't matter

52:16

okay cool now to the fun part uh once again I'm gonna have to use these two

52:23

things so let's copy that and just whack them in there and then this time I need to get server-side props okay because we

52:30

need to get slug so export cons get server

52:37

side props

52:43

okay this is also going to be an async function and then we're going to have to pass through the page context

52:53

okay so this is what the page context does I think it's always worth showing you instead of explaining this

52:59

so if I want to get the page slug wow

53:06

um actually maybe just let's consult console log

53:11

page context so if I console log the page context and then I visit uh so we made a

53:19

directory called video didn't we and then the slug that we used was just two

53:25

jaws because I remember how to spell that uh we need to do a return always get all

53:32

the time actually maybe it would have worked anyway without return let's look in the terminal ah okay so it did what so we just

53:38

console log the page context and that's what's returning to us this is all of the page context all of this

53:45

stuff right here but we need to get the page context query slug see query slug

53:52

so I want the query

53:57

slug okay that's what I want and I'm gonna say this as the

54:03

page slug so if I console log

54:09

page slug now let's visit a different one what else do we have we had Moana

54:15

enter and then we go back to here and look in

54:21

the terminal Moana it's been returned back to us we are

54:26

getting the page like we are essentially getting this uh okay so that works we're getting the

54:35

page slug now let's get to using the page looks we can pass it into our queries we can get the data back

54:40

hopefully that makes sense let's do it so once again I'm actually going to have

54:46

to get the URL so const URL in fact I'm actually just going to copy it from here

54:54

so we get the URL and then also once again I'm just going to copy this from here because this is how we interact

55:00

with our database uh and then we've got the slug the next thing we need is the queries so const

55:07

query equals and I'm going to use the gql tag that we imported so we can write like

55:13

gql and I'm just going to get this whole query right here

55:21

and paste it but of course we need to um replace some of these things so I'm

55:26

going to show you how to do that now so in the query part I'm just going to

55:31

maybe tap this out to some more leaderboard

55:42

so if I want to replace this I can't simply go you know page

55:48

Slug it won't work we need to pass it through as a variable so to do this I'm

55:54

going to open up some parenthesis and page slog is going to be

56:03

a string okay that's required and then I'm going to pass through the slug as

56:09

page slug but this comes from a variable so I need to put const variables

56:18

page so so if I was to show you how this goes It goes oh we assign Pages like a value and

56:24

it goes here or what page slug is now a variable and then when we do this

56:31

graph your client request so once again this is just from the npm page

56:37

documentation I'm gonna pass through a query which is the query wrote along with the variables okay so that's how

56:44

you do it that's how you pass through the variables into this query and then await this

56:53

and then let's save this as data cool so now once again this data

57:00

data videos that's what I need to do data videos to get my videos so what should we call this

57:09

const video singular data video

57:14

so that's what I was gonna come on

57:24

yeah data video okay good thought I was going crazy though okay dirty video cool so we're getting our

57:30

video back and now we need to return it so to do this I'm just going to go return

57:37

props video we can return different things as well but for now we just have

57:44

videos so we've only query for the videos and once again I'm going to pause through a video as a destructured prop

57:49

and it's console of the video to see if everything we want returns back to us so now here

57:58

ta-da we got Moana and if I change the Jaws

58:04

we get Jaws and if I change this to Mulan we get Mulan so we now have enough data

58:11

to populate this individual page two wonderful okay so I think now perhaps it's time to

58:19

actually start building our upfront and Visually with the data that we have so let's do it

58:30

okay so which page shall we start with let's start with the main page

58:37

so this is going to be a bunch of jsx what but jsx but by the way so the first

58:45

thing that I'm going to do is I should just get rid of all this

58:54

and I'm just gonna maybe add some more spaces so we can see things a little bit better

58:59

so the first thing that I'm going to do is actually just create a div and let's

59:04

just call it app so we're just going to give it the standard name of app so we can style this later on

59:11

and how do we want to style our app well first of all let's get some details in here and then probably let's go to

59:16

styling so the first thing so we're going to have a big video so let's maybe make a big a div

59:22

um and let's call it it's also given the class name of

59:27

main video and in it let's put an image so I'm just going to open up my image uh

59:34

let's make a closing tag and then in here the source and my image is going to

59:41

be well we just want a random video for my

59:46

videos right so perhaps we could do that should we do that now yeah okay let's do

59:52

that now so I'm going to write a function here that's going to help us do this it's going to help us get a random video

59:59

so I'm simply going to go const I'm going to write a function const random video oops not in here

60:07

here and then whatever I pass through into

60:14

here which can be all the videos uh I am going to essentially what I'm going to

60:20

do is check the videos or use return then this is math random

60:30

multiplied by the videos length of course you've got loads of videos this probably isn't the best way to do it but

60:36

we're not working with huge volumes here and then I'm going to use math floor to round this down to the nearest uh

60:44

integer okay so that is what I'm doing so the

60:50

math roundabout math random multiply the number will give me uh anything up to

60:55

just under the number itself so if I round that down it will literally come back with a zero or one a two or a three

61:01

and I'm going to pass that back into my videos array to bring back a random

61:07

video okay so that's what's being returned uh so now if I use

61:14

for example math math video run random video and pass through the video so all

61:20

the videos okay so whatever returns back whichever video turns back I'm gonna get its thumbnail and I'm gonna get the

61:26

thumbnail URL so that gets displayed okay and of

61:33

course we need some alternative text because we're not monsters and we need

61:38

to make this uh accessible to everyone so I'm just gonna get these videos titled okay that's going to be our

61:43

alternative text great and this needs to be a closing tag

61:49

here not up here

61:54

okay so this is looking good um of course

62:00

okay let's check that out let's see if that works I'm just going to go back on the main page

62:06

and wonderful so the random film that got returned back to us is a turn oil and if I click it again

62:17

it's a random film each time

62:22

okay great so that is looking

62:29

good I don't know why it's shouting at me but we'll figure that out later

62:36

okay so let's carry it on

62:41

so we've got a random image the next thing I want to do is actually create a feed so I'm going to do that let's

62:50

okay let's make a div and then let's give it the class name of feed

62:57

or video feed and in the root of my project I'm going

63:04

to create a new directory called components and then in

63:11

my components I'm going to create a new Javascript file I'm going to call this section okay so I'm creating essentially

63:19

a section component so const section uh

63:26

and then export default section just like so and what's it going

63:32

to return well it's going to return something that looks like a section so let's do that now

63:40

so what it's going to return is um I'm just gonna make something for now

63:46

I'm going to return a div that has a H3 tag the essentially is going to just

63:53

display a genre okay um and then a video for now let's just

63:58

do one genre and see how that works so I'm gonna pass through a genre like so and I'm going to go back here

64:06

and we need to decide what genres we're going to have so let's import

64:12

section from components section okay thank you

64:19

for that very much uh and then here so I'm going to use the component I've just made

64:26

like so and then I'm going to pass through a genre

64:31

and what should the fashion review what genres did we actually make we have like family I remember that one so perhaps

64:38

maybe let's start with that's

64:45

um okay family I know is the genre so let's

64:50

put that in here

64:55

let's have one two three four five six

65:01

uh family is a genre we also have you know

65:07

star Wars

65:12

uh Disney

65:18

it's what else do they have National Geographic

65:25

um Marvel of course

65:35

Pixar and then let's have some more of this you know once we've got family uh what

65:42

else do we have we had Thriller I think and we had classic

65:48

okay oh oops we misspelled section this needs

65:53

to be a capital

66:06

okay so we're importing this section we're passing through a genre as this

66:11

section and then we're just gonna show the genre okay so there we go

66:18

Tada is just showing up as uh header ties at the moment let's actually stir this up because it's really big and it's

66:24

a bit pixelated and I'm not really enjoying looking at it so I'm just going to start this up a little bit before we

66:30

move on that is called the main video so let's do some styling

66:37

so in here um we can delete this and I'm just going to go main video

66:45

and how should we style it well the width we do want to be a hundred view

66:50

width and then the height let's say it's going to be like 30 viewport height

66:58

uh and then any overflow is going to be hidden

67:05

and then let's also give it some margin at the bottom so there's a bit of space

67:10

between the image and when the other films start and also position

67:18

now let's overflow hidden

67:25

okay so that's what it's going to look like for now I mean I'm happy with that uh I

67:31

think it's fine we'll obviously like when we adjust all this a little bit later and position it maybe a little bit better the thumbnails I chose weren't

67:38

great but you know what can you do okay

67:43

so we've got these let's carry on actually while we're here let's also

67:48

maybe give the app some padding so I'm just going to grab the app uh actually just give it a some margin

67:57

20 pixels just like so and then the whole body well the whole body I actually want to have a different color

68:03

so I'm going to keep the fonts like this I really don't mind or the background

68:09

color um I'm actually going to give it a hex code that I found earlier one three one

68:15

five one f okay so that's what I want and all the

68:21

text from now on is going to be White

68:34

I feel like this isn't in okay so that's outside of that I want it to be inside

68:39

the app

68:45

okay so we're passing through the sections genres however I also want to

68:51

pass through these videos so I want to pass through videos into the genre of uh family however I want to

69:01

filter these videos I just I don't want to just pass through all the videos so I'm gonna do so by filtering out the

69:07

ones I want so I'm just gonna do so here to const filter

69:17

const filter

69:24

videos equals I'm going to pass through videos and I'm

69:29

also going to post through this genre that we want to filter by and then

69:36

I'm going to return so this is how you filter I'm going to grab these videos array this is an array

69:42

of videos I'm going to filter each video okay so whatever so each item in the

69:49

video array I'm going to look at each item I'm going to look at that items tags and if there's tags because the

69:55

tags are an array remember an array of four things and if that includes if that

70:00

array includes the genre pass through then return the videos so now

70:07

if I do filter videos and pass through obviously the videos videos and then

70:13

also pass through the genre of family I can't remember how we spelled it but I

70:18

think that was fine let's see family so that should work

70:27

so let's now check the videos

70:34

okay so now let's check the videos let's see if this has worked I'm just going to console log the videos and see if the

70:40

ones with family have been filtered out

70:45

oops it is

70:55

okay and they have I've got three that have the tag of family

71:04

wonderful this is looking great I'm getting about the videos so now

71:11

that that's worked I'm actually going to make some videos make some little video cards so once again in the components

71:18

I'm just going to create a new component let's call it a video or should we call

71:24

it a card whatever you want to call it maybe let's call it a card

71:31

card Js ad and then in the section I'm actually just going to copy this

71:36

paste that and then place this with card and replace this with a card

71:43

and into the card well what do we want to pass through well I actually just want to pass through the

71:50

what do we need a thumbnail to be fair that's all we really need so thumb now

71:57

okay and what I want to return is it doesn't need to be this long I just want to

72:03

return an image actually that has the

72:09

source of the thumbnail URL okay and then also as

72:16

an alternative the thumb does the thumbnail have a title

72:24

I hope so otherwise we don't have anything to put for the alternative text we'll have a look in a bit okay I know

72:32

we didn't add one but perhaps it comes with one if that makes sense with all the ones that we got added and let's

72:38

style the card in a specific way so card

72:49

and let's style it up so I'm just going to move this all up a little bit

72:55

I'm gonna grab the card and then what how do we want to store

73:00

the card um well I'm gonna make it responsive so I'm gonna say that the card has a width of

73:07

20 and a height of Auto based on the uh

73:12

thumbnail itself let's actually also give it a border radius to sort of round it off so border radius uh let's say

73:20

five percent and a margin around it so they're not all squash together and then

73:26

let's also give it a little bit of a drop shadow Rob shadow

73:32

drop shadow 5 pixels 5 pixels 10 pixels and make the

73:37

color just black okay so now let's go so we've got a card

73:43

let's go to using our card in this section so I'm going to import card

73:51

from it's in the same place so consciousness

74:00

okay so in this section what do we want to do well I think

74:07

we should map over all the videos that come back right so maybe let's get rid

74:13

of or we can let's just keep that for now um

74:19

we're gonna have to start this up so I'm just going to give this the class now section for now

74:27

because we're going to want the cards to uh appear next to each other and not

74:33

unblock so we've got an H3 tag so let us know which genre is and then I'm going to have a video feed again

74:42

okay so I'm just going to give this the

74:48

styling of video feed because we have we've used it okay so I'm just going to

74:55

give this the class name of a video feed um just so we can see each video

75:03

and what I'm gonna do is I'm going to grab all the videos and

75:10

I'm going to use map and for each video in our videos array I

75:18

want to well essentially I want uh to link the card itself so let's link the card I need to give

75:25

this a key an individual key so I'm just going to give it the video ID and then I'm going to link it so I'm going to use

75:32

href yes thank you very much I'm going to go to the videos or videos sorry because that's what we called it video

75:39

Slug and the slug is going to be the video slug okay so hopefully you can see how

75:45

that makes sense I passed through the videos and for each video I'm essentially mapping over each item and

75:52

I'm creating an a tag that has a reference to this

75:58

URL which we've also just created okay so that is looking good let me just make

76:04

sure that I am okay so that looks good and then inside

76:09

I'm going to use the card component to self-closing component and I'm just

76:15

going to well we want to pass through these thumbnail don't we that's what we decided so video

76:21

thumbnail and I think that's what we pass through yeah that's correct that's all we're

76:27

positive great ah okay I don't think we're passing

76:33

through videos into this section so let's do that let's go back in here

76:39

and we need to pass through videos for all of them so videos

76:44

for now I'm just going to do all the videos we can of course replace this later

76:57

so one two three four five six seven

77:05

and there we go how good is that looking I am loving this so

77:13

far we and it's looking pretty responsive

77:18

woohoo um

77:25

wonderful okay this isn't being responsive but we can fix that

77:33

let's go back to here

77:39

so the main video main video uh if any image exists in

77:45

that which it does just make sure uh to make the width a hundred percent

77:52

okay there we go how good is that looking in a family we've already filtered out all the

77:59

videos that are that have the tag family however let's do the rest so this should

78:04

be easy now because we've already done all the grunt work so let's go back to index and I'm just going to

78:11

filter videos I'm going to pass through videos and the genre I want to filter by

78:17

is Thriller making sure to spell it like I did right

78:25

here okay so under the tags right here on the video

78:30

and once again I can just actually copy paste this probably that should be a lot

78:36

easier I'm going to filter by classic

78:42

I'm going to filter by Pixar

78:48

oops videos

79:04

the filter by I mean I know we don't have any National Geographic but

79:12

it's gonna be an m a sad row uh

79:28

filter by Disney

79:39

and filter by Star Wars so unfortunately some of these will be empty we just don't have enough

79:47

data but again I'll show you what this looks like after I've populated with all the data so now it's going to look a lot sadder

79:54

unfortunately but at least we know it's working this is looking

79:59

good Pixar has nothing natural geographic has nothing so that's why it looks a bit weird and Star Wars has

80:04

nothing but all the rest have a few okay uh one more thing I'm actually going to

80:11

have another section and this time I'm going to do recommended

80:19

for you and this is going to be based on what you have seen so how to do this well I'm gonna use

80:27

another function to help me do so and all I'm going to do is do unseen videos

80:35

seeing videos

80:42

and then I'm gonna pass through these videos and then

80:48

I want to return back so once again I'm going to filter I'm going to grab grab the videos array and filter and look at

80:56

each video in the array and if the video is seen

81:03

so if it's

81:10

video scene okay if the video is seen

81:16

equals false or video scene equals Knox we had no it's

81:24

just going to return all the ones that aren't same basically they're not true so unseen

81:31

and I'm just going to do it for this one unseen

81:38

and I'm just going to pass through these videos so now

81:44

I'm seeing videos that should be plural

81:53

ta-da because none is seen we're returning all four videos how cool is that uh we are going to I'm

82:00

going to show you how to change scene uh with a mutation in a bit but for now

82:06

let's actually carry on so we've done that we've created some sections the

82:13

next thing that I'm gonna do is actually create a

82:19

what to ask me to do on this page well we should probably have a nav bar I know there's a nav bar on here so I'm just

82:25

going to create a component new

82:32

Javascript file let's call it navbar to s add

82:41

and once again I'm just gonna have const nav

82:46

bar equals and then export

82:53

default nav bar

83:02

and return

83:09

div a div that we're going to style as a nav bar but what do we want inside it

83:14

um actually let's throw this class name now

83:20

oh let's just do that for now however you want to spell it it really doesn't matter and then well let's just what

83:28

should we do I'm going to actually use Link for this because I'm going to show you how to link to another page so I'm going to use Link from next Js

83:46

and what I want to do is link an image which is going to be our Disney logo so

83:52

image

83:58

and the source of this is going to be uh the Disney logo

84:06

uh the alt for this is going to just say Disney

84:12

yoga doesn't need to be in these

84:17

width I can set the width if we use these images from next so I can set the width in here to

84:25

be 90 and the height uh I don't know so let's just say 50 for now

84:35

okay so we've got our image that's actually imported so we can use it so import

84:43

link from

84:49

next link

84:54

and also import image so import image next image great and now I'm going to

85:02

show you how to work with images in your next JS project so I'm just going to go into public this

85:09

is where you're gonna have to store it so with the favicon

85:23

I'm just going to drag that in here

85:29

add so now that's in there I can actually import it to use it so I can import

85:35

let's call it logo I can call it whatever I wish from and then we just need the path to it so I'm going to go

85:41

into public and then I'm just going to grab the Disney PNG okay and I'm just going to

85:47

use it here

85:52

great so that's our navboss so far um let's actually also

85:58

well let's get to using it first so in my page here I'm just going to import the navbar

86:05

and then import it oh so that's already been done for me so now if I look here

86:20

okay so we need we forgot to do this I'm just going to make this go to the home

86:26

page so I'm just going to put them but that is how you would link it to the

86:33

home page and there we go we have a logo let's actually start this navbar up so I'm

86:39

just going to grab that and just place it up here I think that's

86:46

where a nail bar should go

86:51

and I'm just going to give a height of let's say let's just hard code AS 80 pixels

86:58

and width of 100 cents

87:08

again I'm not going to go wild on The Styling I don't really think this is a styling lesson this is more a lesson

87:15

about using uh the graphql content management system

87:22

okay so that looks good um sort of

87:28

uh okay we will fix that uh I don't know we should we should we add the account now too okay let's add the account

87:36

so actually maybe let's leave that to last

87:41

so at the moment we've got a navbar and everything looks a bit bad but we'll fix it uh I want to display a single

87:52

move if I click on one of these so this is working it's going to the correct thing but now let's actually populate

87:57

this page with some stuff so let's go ahead and do that so I'm just going to shut down some of these

88:04

I'm Gonna Keep the CSS file and get the slug page up

88:10

okay so we've got the video what do we want

88:16

to happen with it well let's keep that up there for now

88:21

so I just want to return essentially an image

88:32

and the uh source of this image is going to be

88:39

well it's going to be the video whatever the video is thumbnail URL so I'm just going to start

88:46

with a thumbnail and then as an alternative let's have the video title for the

88:53

visually impaired

89:03

okay so that's our image with all of its stuff inside

89:09

oops so we've got an image the next thing we want is uh

89:16

I guess the info right so let's make another div that's going

89:22

to hold a we could show all the tags so video

89:28

tags and then we can also show another let's

89:34

have another paragraph with the video description

89:44

okay and then just a little tag to go back so just go back a page because we

89:50

don't have a navbot in this there's not one on the actual Disney site so we're not gonna have one here we're just gonna

89:56

have a little a tag that says go back uh okay so we've got that and then we're

90:03

gonna have a button that says play so have a button that says play

90:09

Okay so there we go if you look at this it won't look too exciting for now there's our

90:15

thumbnail and there's like all the information and stuff let's format this a little bit better let's get the tags

90:21

and on the tags I'm just going to use join to make this a string that's joined together by commas

90:28

like looks okay so that's looking a lot better I've got the description we've

90:34

got to go back and we've got play it's a button play button button great

90:41

okay maybe let's do some styling so let's go ahead and do that how we're

90:46

going to do this well the first image um let's give this a class name so we can

90:52

figure out of video image

91:11

just gonna get rid of this for now and put the star shape over here

91:17

so just get the video image like so

91:23

now the video image well obviously is going to have a width of 100 and then also a position of absolute

91:31

okay because we don't want it to move and we want the info to go on top of it so I'm just going to fix it to the top

91:37

okay and now let's grab the rest of this so I'm just going to grab this and call it

91:43

the info it's a class name info

91:48

and let's style up info so info

91:54

it's gonna actually have a position of relative this time and margin from the top so it's always

92:02

going to be 30 from the top and margin I've used view widths and View Heights

92:09

and percentages I should actually clean this up I will clean this up when I actually share the code so just be aware

92:15

of that or at the end we'll do a little cleanup session so margin left 50 pixels

92:20

and then let's also have a Max width of it so it doesn't go all the way across the screen but it's always going to be

92:26

just 50 percent okay so that we go that looks a lot

92:32

better again sorry about the pixelated image I should really use better images but there we go so that looks really

92:39

good so far let's carry on a little bit with the styling

92:47

I'm just going to make this a P tag so that it's consistent with everything else and then we've got the button the

92:54

button well okay the button is going to do quite a lot uh let's give it the class name of

93:01

video overlay

93:07

it's gonna grab it here so dot video over play

93:13

and I'm going to give it a position of absolute

93:18

okay so at the moment doesn't do anything but what I want to happen is if I click on

93:23

the button it will essentially show me a pop-up with the video so just like in the real app so all I'm going to do is

93:31

write on click just like so and then write a function of what

93:36

happens when we click on this button and what I want to happen is essentially I

93:42

want to set so I'm going to use use state for this uh I'm going to say so const watching

93:50

set watching equal and then use State and

93:55

it's going to start off as fast because we're not watching okay we're not watching when we start this off is you

94:01

state imported now we need to import import use state

94:06

from react

94:14

okay so hopefully you know how to use use State essentially all I am saying is

94:21

that to start off the state is false so this gets set to false watching is false but to change watching to true I can use

94:29

set watching and what I'm going to do is say

94:36

if watching is true so if we are currently watching are we watching I'm gonna set watching

94:43

to false okay so if we're watching and I click this button then I'm going to

94:48

click it to false change it to false sorry and otherwise if it's before not

94:54

watching and I click it I'm going to set watching to true okay

95:00

so I have done that I've done that because I want to essentially show a another

95:07

component if watching is true so if watching is true then we want to show

95:17

this component or these elements I want to show the video tag

95:23

okay this is how you use the video tag and the source for the video tag is going to

95:29

be well I'm going to use source video MP4 URL and then we need to set

95:36

the type to be video MP4

95:41

okay and then we're going to actually have

95:47

the video uh so we have okay yeah let's make it

95:53

with a hundred percent you can set that in here or we can set

95:58

it in the CSS it is up to you so 100 and uh I'm gonna give it some control so

96:06

you can see you can play it and so on and stop it from playing

96:11

okay so let's check that out now if I click play

96:19

the trailer shows up wonderful

96:25

how good is that we of course need some styling and we need to figure out a way to you know hide it so let's carry on

96:34

values this works this is looking good we don't need that much space for the styling so when we are watching we want

96:40

to show this however when we are not watching but we don't want this to show up we

96:46

have to do two because of the way I've done this so if we're not watching

96:52

then we want the image to show up and also if we are not watching

96:57

I'm not watching bang watching essentially not watching then we also we're not watching that we want this to

97:04

show up otherwise when we are watching we want that to show up okay

97:09

so that looks fine uh and then do we need to style this

97:16

yeah okay fine

97:27

let's refresh that play we're watching we're watching and then we want to click

97:32

off it so let's do it if we click off it like off the image then it should disappear so for this I'm actually just

97:39

going to add a footer

97:45

so just below here let's make it a div uh class name

97:53

info footer and then

98:00

let's style it up so let's make it quite large in the

98:06

footer let's give it a height of

98:11

100 VH now if we click so on click of this

98:27

well what do we want to happen well once again if watching this time of

98:33

watching for watching then set watching to

98:38

false otherwise null okay we don't want to start the video if we click the photo

98:43

okay we don't want anything to happen so that is looking good let's check it out again play play the video we

98:51

couldn't make it autoplay if we want and if we click here then we go off it video no video video no video looking

98:59

great I mean this is looking so good I'm really happy with it so far

99:06

um okay wonderful so we've done this now it's time to do

99:11

two more things before you really get to styling this up fully so I need to do two things let's get the uh account info

99:19

up and then let's I'm going to show you how to make a mutation to change the scene from fossil null to true so let's

99:26

do the Avatar bit first

99:33

so we don't need this for now

99:41

I'm gonna make a new query in here so we need to rename this uh something let's

99:47

change this to oops not in this one

99:54

this is where we need to make a new query so we've got a query but I'm going to change this to videos

100:01

query and don't forget to change it

100:08

here too so we've got one query however we need

100:14

another query and that's to get the Account Details so const account

100:20

query equals gql I'm going to use the tag

100:25

now how do we query an account let's go back here and I'm just going to just make a new query so again we can use the

100:33

documentation for this so let's look at the queries available to us so I'm just going to write query

100:41

and this time we need to query an account

100:46

okay so I'm going to query an account and then where

100:52

so this time we're going to search for an account where

100:57

ID is and then we need to get the ID of my account okay so this is how we're

101:04

choosing to do this of course you could do it however you wish so if I actually look in here in my content and I look at

101:12

the accounts and I just have a look at this one I can see that this is my platform that I'm associated with

101:19

however what is my ID here is my ID so I've just copied that

101:30

let's go back in here I'm going to paste that and what do I

101:35

want return back to me well I really just want my username and other time

101:42

so I think that should be it username

101:54

and advertise an asset so I need it URL

102:02

so if I search for that there we go so that is the correct query let's carry on

102:09

so all I'm going to do is paste that query like so

102:16

so we've got our query so I'm just going to use this again I'm going to essentially get our data except we

102:23

shouldn't call it data again we can't use data let's maybe call it account data

102:31

and I'm going to use the weight graphql client and request this time I'm going to request the account query okay and

102:38

whatever comes back well we know that it's going to be account data

102:48

dot account because we just saw it here account data which we've saved to data

102:55

which we saved as account data account and that's what we need okay so now that we have that

103:03

let's actually return it and pass it through into our component so account

103:09

okay great so we have the account however I'm

103:15

actually going to pass through this account into the nav bar so account

103:20

just like so because that's where we want to use it we want to use it in the Napa

103:26

so now let's get our nav bar I'm going to pass through the account

103:34

and now let's actually uh use it so here we have our navbot again we've got this

103:41

link but then let's also have

103:47

some account info so I'm just going to make another div

103:53

um and then maybe let's call this count info oops

104:01

account info and inside the stiff well I just

104:06

want to P tag oops

104:14

uh that says welcome account username

104:26

and then maybe let's have an image as well so I'm just going to do

104:31

image class name

104:40

avatars gonna have to style it up and the source of the image is going to

104:47

be the account Avatar

104:52

you are up okay

105:00

this needs to be curly braces okay so this is looking good

105:08

let's see what that looks like let's go back to the main page

105:15

okay so there we are let's get to style this up a lot smaller than it is now

105:22

so once again I'm just going to get my CSS file

105:33

let's get the account info I'm just going to use display Flex on it

105:44

let's also give it a height of 50 and the Avatar itself about Tara well I want

105:51

the Avatar to save you 50 pixels width uh and height also 50 pixels

105:59

and then border radius uh 50 and I think that should be fine let's

106:05

maybe space it out a bit as well so I'm going to give it a margin the left of 10

106:11

pixels order radius okay

106:19

okay so that's looking good and now let's actually just space this out in between so what is that in that is in a

106:25

nav bar so let's find the nav bar and I'm going to do justify content

106:33

space between wonderful and of course that could do with some

106:39

more styling but we're going to leave that because we have one more thing to do before doing the refactoring the

106:45

tidying up and the final pieces of styling and that is do mutation

106:51

so

107:00

to make a mutation I'm just going to shut all this down because we're going to be doing this in the slug page so to

107:07

make a mutation I actually need to make this in the API I'm going to create a

107:12

new Javascript file and I'm going to call it change to scene

107:20

just like that and this is how we would do this so here

107:29

is the syntax um export default async

107:36

and then I'm gonna have to pass through a body and a resp response if you're used to

107:44

doing uh you know serverless functions this is kind of similar

107:51

so there we go uh here we are and then I'm also going to import the graph

108:01

ql client from graph

108:08

ql Quest because we're gonna need it okay

108:14

so once again we're going to make a new graphql client and I'm going to pass through the end point again so the URL

108:20

so process EnV end point so just like we were doing before URL and then the uh

108:27

token so the headers with the token and then process Envy

108:33

graph CMS token okay so that we can communicate with our database and now we're going to

108:41

have to do this so oh wait once again I'm just getting this from the graphql request documentation if you want to

108:48

check it out um graph CMS request

108:58

and the request I need to make is the mutation so the mutation that I need to

109:04

do to edit a let's make a new thing so the mutation that I need to do is looks

109:11

like this so I'm going to go into the mutations

109:16

okay because we just use the documentation for this so mutation

109:22

and what I'm doing is overriding one of the video uh I guess

109:28

elements that I have one of the video objects to have seen from fossil not to

109:34

true so all I'm going to do is essentially use update video

109:41

which videos I'm going to use where

109:46

and I'm gonna do it by slug so if I do Jaws

109:53

oops okay so if I do chores

110:03

and the data that I want to pass through is seen

110:09

true

110:17

and then I'm just going to return the ID and and the scene

110:27

okay and the title okay so if I do that

110:32

we've changed the video to have seen as true I can change it by defaults if I

110:38

want cool but of course we just need to send it CO2 because you can't unsee something

110:45

so this is all that matters I'm going to take that I'm just going to put it in here

110:53

so that's a mutation but of course we need to pass through this slug so I'm just going to this is how you would do

111:00

it uh and I'm also going to get this slug which is the body Slug and then I'm

111:08

going to replace it in here with the slug so I'm just going to pass through the

111:13

variable so slug is going to be a string

111:20

and I'm just going to replace it here with slug so now whatever I pass through in

111:27

here okay will be changed so that is looking good I'm just gonna

111:32

do 201 is going to return with adjacent

111:47

okay so this is looking

111:52

good uh graph CMS we didn't Define graph CMS oh yes constant graph CMS

112:01

of course so that's called CMS okay okay and now we just need to write mutation

112:06

to publish the video so it's just the same as above it's just a different mutation so I'm going to write a weight

112:13

graph CMS requests mutation publish video which is the mutation that we need

112:19

and I'm going to pass to a slug as we're going to find the video by its slug so

112:25

we can publish it okay so I'm defining this I'm saying this slug is a string and then I'm just going to write the

112:33

mutation that I need to do I already know it because I have done this before so publish video I will show you where I

112:42

found this mutation though so don't worry publish video and I'm just going to put where slug and this is going to

112:48

be the slug that we pass through from the body so just like above from the

112:54

body and then I'm going to say to publish and

113:00

just to check this has worked I'm going to return the

113:05

so just in between here I'm going to return these slug okay so that is really it once again we need

113:13

to pass through the variable slug so we're going to take it from the body and pass it through as a variable

113:20

and I'm going to say that the slug we pass through from the body I'm gonna

113:27

assign this to slug so I can use it in the mutation okay so this is looking good don't

113:33

forget the comma great great so that is the mutation to publish

113:39

the video okay and this is where I got it from so just in here on the mutations

113:49

I'm just going to search for it there we go that's it okay

113:56

wonderful great so we've got the chain C now let's get to using it in here

114:06

foreign so let's write a function for this I'm just going to do it above here so const

114:16

change to scene

114:21

async it's going to be an async function and whatever slug I pass through

114:27

the one that we're going to send to the mutation okay so I'm going to use a

114:32

weight patch for this and I'm just going to pass through the URL that goes to my API change to scene so make sure you've

114:39

spotted exactly the way that you've spelled it here change to scene

114:44

uh the method it's going to be a post and headers

114:51

well we're going to have to say it's content

114:56

type application

115:02

making sure just to keep everything a bit more consistent okay

115:09

and then of course we need to also posture the body

115:14

Jason stringify on the slug

115:21

okay so we've written the function that essentially will use our mutation and

115:27

then on click so when we click the play button well we're just going to change scene change the scene and we're going

115:34

to pass through the video slug great

115:39

so now that should work let's check it out

115:44

okay so at the moment we have four films which are unseen and recommended for me if I click on one of them however and I

115:52

click play so there we go we're watching Moana watching Moana it's a great film love

115:58

Moana whoa and now let's go back to the home page

116:05

okay so now we can only see three films in the recommended this is because we

116:11

changed the scene from false or no to True okay so there's only three films in

116:18

here now this wouldn't work if we didn't publish the video just an FYI that's why

116:23

we need to publish the video uh and now if we want to change this back I'm just going to do this in the graph CMS so the

116:32

playground I'm going to once again just grab the mutation that we wrote before

116:37

and then I'm going to change this to scene false

116:43

okay just because I want all four to return back but hopefully you understand how this works now uh if I played the

116:49

video on any one of these cards again it would change scene to True again okay

116:54

so hopefully that explains that let's carry on with some styling

117:02

so all I'm going to do is actually get a div let's make some divs uh and I'm

117:10

going to actually make a div and give her the class name of a franchise because I want to then link to other

117:15

sections in here so on this page so class name franchise and then I'm going

117:22

to give this the ID of Disney so we can style it up

117:28

as we need and then let's actually wrap this up in

117:34

something so we can use an a tag

117:40

I'm just going to grab this stick that in here and use the H Rev

117:49

in order to go to Disney okay so now I'm going to give this the

117:55

ID of Disney ID equals Disney so then if you click on that it

118:04

will take us to that genre and I'm going to do these same so we've got one for Disney I need five two three four oops

118:12

four five we've got Disney let's have Pixar

118:18

let's have Star Wars let's have Nat Geo

118:25

and let's have Marvel

118:31

oh once again Pixar

118:36

Star Wars not

118:42

Geo Marvel and let's give some ideas

118:49

so ID not Geo

118:55

ID waffle

119:10

ID Pixar an ID

119:15

Style horse it's great so that should link to those

119:21

things whenever we click on it and of course let's actually style it up so I'm

119:28

gonna get a show you how to make a little franchise one so I've got franchise

119:37

let's give it a width of 20 percent a height of 100 pixels

119:46

a background color of

119:51

Gray is that 8080 18.

120:02

margin 5 pixels water radius

120:09

10 pixels

120:15

okay and then in here what does that belong to video feed

120:21

dot video feed display Flex

120:31

I'm actually just going to change these to Links just to make it more uh friendly

120:50

and then import link import link from

120:57

next

121:14

okay so that is actually going to be part of a video feed like so

121:26

now let's get the class name of section I'm just going to go back here and

121:32

actually delete this I don't think we need it okay there we go

121:38

wonderful so this is looking a lot better one last thing to do and let's sort this out and

121:44

then maybe make some images for these so I'm just gonna go back in here

121:52

get the nav bar and make a div here called

122:01

logo

122:06

Rapha stick that in there

122:20

logo wrapper I'm giving a pattern of 10 pixels and 30

122:26

pixels

122:31

so 10 from the top and 30 from this side great

122:36

and finally the navbar itself and I'm just going to give it a

122:42

padding pop with 30 pixels

122:51

you count info margin

122:57

top and pick

123:03

and pick 20 pixels

123:12

margin 20 pixels okay

123:19

so what I'm going to do is just drag in some image that I'm going to use just drag them in like we did before so here

123:25

they are just some logos just going to get rid of this and all I'm going to do is use the image

123:33

from next image and then the source and pass through the image okay which we're

123:38

going to import into this file so again just like we did before so let's import

123:43

the image import image from next image okay great and I'm just going to get rid

123:51

of these semicolons great now we need to import the logo so

123:57

let's do Disney first import Disney logo from and then the path to where I store

124:03

the PNG file so public Disney button okay this actually doesn't need to be in

124:09

color braces it's the only thing in there that we need and then I'm going to do it for all of them so Marvel Marvel

124:16

button then we have then we have not Geo not geobutton then

124:24

we have what else Pixar this is actually just this this is just Pixar PNG that's

124:30

what we saved it as and then let's also have Star Wars so Star Wars logo okay

124:36

just like that and we saved this file as Star Wars button PNG

124:42

so they're imported now let's use them so the image uh this actually needs to

124:47

be in between the two divs sorry so the image for that should go here and

124:53

wonderful okay this is looking good let's carry on so we've got one logo in

124:59

let's do the others before we move on though the div that we

125:04

are currently in the height is fixed I don't want that so I'm just going to get rid of that from here so I'm going to go

125:10

here and enfranchise because that is the class name that the div has I'm just going to delete the height and great

125:17

okay so we have that done let's do the next one in between these two divs I'm going

125:23

to put in a logo in between here as well and in between here and what should we call this well that's

125:29

Marvel logo and now we just need to pass through the Marvel logo pass through the internet

125:36

Geo logo the Star Wars logo and the Pixar logo great and I'm just going to

125:42

format so reformat the code I can do so super easily in webstorm I can actually

125:47

just reformat the whole project by clicking here and then going under the

125:53

tab code we format the code great and now my whole project has been

125:58

reformatted um it also tells me started spelling mistakes so that's handy thank you very

126:04

much Geographic and what else can we do

126:12

sometimes I feel like I put the class name in Cali braces and I don't want

126:18

that I just want the class name to be a string so let's find where I did that

126:23

because I definitely did somewhere

126:30

out there okay so I like to keep class names like this but again it's just my preference it is totally up to you

126:37

so great this is looking good okay it's final look

126:46

wonderful um and delete any console logs as well so let's just get rid of this console

126:51

log here great okay

126:57

okay and finally let's do some final styling so I'm just going to do a little bit of this

127:03

I mean it's essentially all fine I'm just doing some final touches so

127:10

and that's it thank you so much for following on to the tutorial please go ahead and take this project make your

127:17

own improve on it really take it to the Max uh I can't wait to see what you build with it and I'm really excited to

127:25

see the results so thanks so much again for watching and I'll see you soon

 

 

No comments:

Post a Comment