What is GraphQL?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hated everyone if they share back again without the video and in this video we are talking about graph QL so yes we all have heard quite a lot about SQL structured query language now what is this new term graph QL what does it even means what are its advantage and where can I use it there are a lot of questions that are hanging around questions like how does it makes my life easier should I be implementing in my next project and the most important question is should I abandon the rest API now that the graph QL is here and what exactly this graph QL is if somebody asked me define it so how can i define it what actually it means we're going to answer all of these questions in this video so let's get started [Music] first and foremost the biggest question is what is graph QL now graph QL was designed by Facebook and if you look at the definition on the Facebook actual homepage of graph QL it's gonna say something like this graph QL is a query language designed to build client application by providing flexible and intuitive syntax for asking the data requirement by the clients yes this is exactly the point where the definition is totally correct but it is so hard to understand for a general public like you and me so let me break down this into smaller and easier syntax so that you can understand it the main goal behind designing the graph QL was to make the query smarter now so far we have been designing these queries and designing the endpoints such as an API pretty easily and the only problem with them is over fetching or under fetching sometimes the data is so less that you have to make another query or sometimes data is coming up that is so much that you don't use all of the data you just use select a point of the data nothing big much of every but when you are at a scale of Facebook we are billions and millions of people are just creating data every single second then it can be a little bit expensive on the cost of server because a lot of queries are being fetched and data is being transferred so if we take a very simple example let me just tell you that we want to fetch a certain information on our website for example give me the name age height and the highest score of the top five player that played in 2005 World Cup the Cricket World Cup yes it can be done we can fetch the queries but now assume the data that you will be fetching it will be surely an over fetch you will be fetching a lot of information and then will be nitpicking the information that is actually being asked most of our REST API applications looks like something like this / player / player called an ID + / country / teams and something like this often these endpoints which don't have any IDs just give you all of the information for that endpoint and often the these endpoints which do have an ID they gives you the information about one particular resource but again the information is completely full whether you require that information or not it is being served to you so for the IDS the Hoth information is dumped and for when you don't have ID like it's it's gigantic information at that point the only advantage that we get when we mentioned the ID is we are asking for one particular resource that we are looking for but still a lot of information is being done I'm not getting just the name the height and the highest score of that player I'm getting a lot of other information like what is this last name what is his email id probably username and a lot of other information now imagine you are fetching up 100 IDs for example you will be making 100 API requests and hundred response will be given to you and now you are collecting just five information out of that yes that is very very cost expensive even for Facebook but surely Facebook can afford all of this queries because hundred queries is like nothing for Facebook but here Facebook eventually thought that hey we can cut down our resource if we act a little bit smarter the solution actually came in the form of graph QL in the graph QL you can make selective endpoints like you don't have dumb endpoints you can pick up selective information from that endpoint using graph QL graph QL can dig a little bit deeper into your API endpoints and can pick selective information from it now if I had to compare the graph QL and the REST API I would be comparing with the restaurants now here the REST API I would be comparing it as self serving restaurant kind of a buffet and for the graph QL I would be comparing it with a restaurant that is being served by waiter now in a restaurant where you are served as a buffet you just get up from the table and you just go on to each and every table and select the desert from there maybe you will go and select some vegetables or some breads or something like that but on a restaurant which is served by waiter you actually make smart decision just by sitting on your table you ask the waiter hey I need a bread I need a pizza I need a pasta and I would like to have a vine as well waiter will go to each every table will select the pickup all the required things that you have asked and it's gonna serve to you so that's actually a smart decision now again this should not be considered as the graph SQL is all amazing and it's all awesome sometimes your application actually don't need that kind of dig up into the information and that kind of resources that you need to implement graph QL remember not everything that comes up as a new is not always all rainbows and sunshine there are always pros and they are always cons on to a whole summary note I would say that when your REST API becomes smarter that's actually your graph QL now here's a quick screenshot of how the graph QL queries looks like and how you can select and pick up some selective information that you actually require I highly recommend to pause and take a look it's a very small dump-down example but I think it will give you a better example and scenario of how the graph QL looks like okay so now that you know a lot about the graph QL let's also address some of the common question that floats around over the internet so I'm gonna be picking up some questions and we'll be answering them related to graph QL the first and the most common kind of amid that floats around is is graph QL related to graph database now in case you don't know what the graph database I touched upon it a little bit in my new SQL video so go ahead check that out it just allows the video so the coming back on to the question is graph QL related to graph database the answer is no it's not yes I know it it involves the word graph and the graph database is here it's somewhat kind of a situation where Java and JavaScript are being are being compared similar to like car and carpet they have nothing to do with them now similarly the graph QL and the graph database has mostly nothing to do with that surely it can be implemented there as well but the world graph here in the graph QL simply means that our queries are now able to crawl into the rest API and pick up the Selective information so that's why the name graph actually came up and the QL you already know it it means queried language our most important question that usually the new developers seek around is should I just abandon the rest API and always should use craft QL Sh is there like no usage of REST API now I would say no most of the application now at present of the time recording of this video don't actually need graph QL now most of the application are working fine with the REST API and you don't need to implement another resource just to have graph QL now I'm not saying you should not do that if you do that that's always going to be advantageous and it's always gonna be fun but there is no such high an immediate need that you should implement graph QL remember we are talking about the graph QL where you have millions and millions of query being thrown at a single day usually that's not the case for most of the application and remember if that's the case for you you obviously have the resources to implement graph QL you will be earning that much for sure in prison world graph QL is an amazing knowledge that you should look around but this doesn't mean that the REST API is going anywhere they are still rock-solid they are gonna stay here and most of the applications still are just fine with the REST API also your application is not gonna see a night-and-day difference in the performance when you'll apply the graph QL surely for Facebook it's a night and day difference but for most of the application that you and me are designing and are working on it's not gonna be a much difference there another common question is what is the syntax difference between the graph QL and the rest API now the most common difference is in the REST API you just mention something like player and ID and it's gonna throw all the information in front of you well in this screenshot you can see that when you make a query for the graph QL you can nitpick and select the information like name and website of that particular ID so that's the most basic difference surely there are more but I think this is the most basic one we should discuss in this video another common question is if I need to get started with the graph QL what should I need what is the requirement and how I can proceed in order to learn it now in order to learn the graph QL there are two requirements first of all you need a server that can serve your API and you need a client where you can fetch all the endpoints from the server now for the server you can use node and graph QL jes and of course you can use Express with the graph QL to make these servers but again there are no such shortage of that and you can also use Apolo although I haven't personally used a polar but there is a lot of good words in the market about Apollo and neither I am associated with them as well so I have heard pretty good words about the polar day to have server as the client as well but most of the developers that I talked and I work with they have always preferred the usage of the node with Express and the graph QL so that they can design their customized graph queue else now for the clients also you have variety of resources you can use to relay but remember the point that relay was once an internal tool for the face book so when you'll be using you'll be feeling more like that hey it's overwhelming and I don't need that much of the information or that much of the ability that this tool is able to do so again remember that this was once an internal tool at the Facebook surely Apple Oh does have a client but I haven't personally used it anywhere so just feel free to explore it the more you are gonna explore the more you're gonna learn for reading purposes the Facebook official documentation is pretty amazing very very elaborative and one of the well written documentation for the graph QL so make sure you check that out as well okay so this was the whole detail about what is graph QL and some of the important points that I wanted to discuss about graph QL I know these kinds of videos sometimes stretch a little bit longer but these information need to be packed up in just one video so that we can just make a precise point that hey if you want to learn graph QL that's the video you can look at and that's the great starting point I hope you have enjoyed this video in case you have enjoyed this video your simple thumbs up can really be a great motivator for me now in case you want to add something more about this graph QL and some information related to it or maybe a discussion I will be looking forward in the comment section and one more thing if you want me to make video on another such technology your suggestions are always welcome I read all of the comments so go down in the comment section and let me know what more subjects should I cover I would love to make videos for your demand that's it for this video and in case you want to look forward for more videos and want to get notification hit that subscribe I can and yes YouTube has introduced a bell icon which you mostly might be aware because every youtuber says that hit that subscribe hit that Bell icon so you already know that I don't need to say that although I say it but anyways just hit that subscribe I can and we will surely catch up in the next video [Music]
Info
Channel: Hitesh Choudhary
Views: 122,606
Rating: undefined out of 5
Keywords: Programming, LearnCodeOnline, What is GraphQL, GraphQL, facebook graphql, graphql tutorial, graphql vs rest, REST API
Id: X3QM6Ap6u-4
Channel Id: undefined
Length: 12min 3sec (723 seconds)
Published: Thu Jun 28 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.