I'm taking your React course on Udemy right now, it's so great seeing you on so many platforms teaching and passing on your knowledge! I always find your tutorials helpful, easy to follow, and you convey concepts very succinctly.
I appreciated how unbiased this comparison was. I think one major thing GraphQL has going for it is that is a standardized spec. There's a lot of variation in the quality of REST APIs.
This helps to expose just needed data, as per mobile you must limit to only data needed avoiding waste of mobile data... Yet there are a server layer of control before the db, but in the end it's sql in frontend lol
Lol yes! It’s more of a generic way of storing the query columns and filter clauses, instead of having to deal with building the Rest api url (and body) dynamically. Imo it beats rest api hands down, it may be a standard but a sucky one at that!! Just create a config file for the GraphQl queries, to load them up and use them on your frontend, it can be managed a lot more easily than a Rest api. This the reason Stored procedures became so useful back in the Sql dbs days! Precompiled execution plans, highly maintainable and can return sql select data as well as receive input params (sql server supported even complex inputs like xml)
Not sure why this is a versus video... since pretty sure most people use still rest api... and use graphql as a data layer (.. middleware sort of) or am i missing something?
Was looking for you..! 😝 Who agrees that life revolves in circles. Checkout some topics which are making a comeback below 1. Server side rendering with React ( JSPs were using this) 2. Libraries are being preferred over UI framework (returning back to jQuery ? 😝) Your thoughts would be nice 😂
Felt like i skipped a step somewhere, started web dev with plain html and css for regular static sites.. now we use gatsby and typescript to generate static sites... Is it worth it? probably not... but I get paid to do it!
I had a job interview before 2 weeks ago. And I was asked if i know what a GraphQL is, well i didn't knew cause so far i've used only Rest APIs and never had to dive in into the GraphQL, but now thanks to this 17 minutes video, I can understand the concepts behind the GraphQL and for what is used for. And I would like to thank you! All of your videos are very well structured and explained in a way that everyone can understand. I own almost all of your courses on Udemy and I learn a lot from you. Your courses are very well focused and cover lots of topics that most of the instructors are considering as "not important enough". So keep up the good work!
Здравей, Наско. Аз съм Митко, от академията на Скейлфокус. Ти ме интервюира накрая с Александър, ако се сещаш😂. Тъкмо виждам коментар от българин и виждам, че си ти😂.
@@Devillman90 Да, разбрах... наистина жалко. Аз започнах, предполагам си изиграл роля да ме вземат 😂. Благодаря ти. Иначе, Макс има супер content. Ако не беше неговият курс за ng, нямаше да завършя академията. 😂😂
@@dimitartanev97 Да добре се справи на интервюто! Радвам, се че си започнал. Пожелавам ти много успехи в компанията! А за Макс да прави доста добри видеа малко подробни на моменти но по-добре така от колкото да остане нещо неразбрано :)
With this kind of videos from Max, huge course on the topic is on the way, I'll buy it even before he releases 🤣🤣🤣🤣. Thanks bro, I like your teaching. Greetings from Tanzania 🇹🇿
3rd party caching with REST is easier, like varnish or nginx, and is also possible to say witch data you want with REST API, that depends on the design you choose to go with.
Great explanation of the overall purpose of GraphQL and how it fits into an application. Heard about GraphQL the other day and wanted to know what it's about.
One of the biggest selling points of GraphQL for me was actually when fetching large amounts of data. With rest i would need multiple requests to different endpoint something like /users -> /users/id/comments (the last request times the number of users), where the second request has to wait for the first one to finish. But with GraphQL you can make it in one swoop and get everything you need. Also you can get data, put data, trigger a utility function, or really anything all in one request. You could literally trigger every single function and resource on the server at once.
Netrole Im sold thanks to your comment! I was wasting so much time pondering what the best method was for me to save a freshly made document, then reference the objectId for the user documents in one go but no avail. It sounds simple but I’m only in the beginning stages of my app. I know I’m going to be making a ton of more requests like that and it really just annoyed me how complex i know it would have be. Awesome to hear there’s a solution to this :)
@@Netrole Isn't graphql doing just that? Multiple queries in the background? In an unoptimized way. Just like all those other trendy tools (webpack, react, Vue...) you just trading code speed for coding speed. Nothing wrong with that as long as you are aware of it.
@@Kiev-in-3-days If you dont run complex calculations on the server, code speed really isn't an issue. The real time killer for web apis is network latency. Having a single request instead of multiple consequtive requests saves a lot of time in network latency. I once had a case where i was calling an api and it took 500ms to return with some ids, then i had to follow up with about 5 parallel requests with those ids, which took 300-500ms each, and then some of those requests needed another follow up request with about 400ms until i had everything i needed. So obviously that is some pretty messy code but also pretty slow, about 1400ms. So i asked the api coder to give me an endpoint where i get everything i need in one request. A request to this endpoint took about 700ms, quiet a bit faster. So the code speed was not the major issue.
@@Kiev-in-3-days In the case described by Netrole where the client has to condition the requests and wait for data from the first request, the GraphQL design would have better performance since you don't have the network overhead. It's a pretty powerful example.
A big difficulty I faced when going for GraphQL over REST is that the complexity/unpredictability of requests makes it very hard to optimize the handling of requests. I mean, if the structure of a request just happens to not play nicely with my database schema and I didn't catch this type of request manually, GraphQL might (and many times does) handle it very inefficiently.
that just means your solution is not well planned or the package you're using for the implementation is difficult to work with. I don't mean this as an insult but here's how to go about it Your schema is like your route description in rest right , since it basically describes what query term to use and what stuff you access to . then Your resolver is the handler for the request it will contain the arguments. now your revolvers should talk to a controller/controller Facade that will give it access to the resources it should expose. this means that your resolver function doesn't have direct access for the db. hence, you just need to write controllers that will return to you resources you expect in the revolvers. So even having complex nested schema definitions will still be resolved quite easily in this approach since each sub nesting or a resource mutually exclusive from the schema definition can still be mapped in this regards. now , for the package you should use , if you're using graphQL in node , then i would highly highly recommend graphQL-js. github.com/graphql/graphql-js , as it will take the pain and suffering caused by sdl and make it baked into the framework itself.
@@abeplus7352 Abe Plus tanks for the detailed response. It may very well be that my implementation approach wasn't well thought out. I was just testing GraphQL on Django with Django Rest Framework. Loved it on the client side. I'll definitely give it another try as soon as I get my hands on a project that could benefit from its features.
FangerZero Graphql is the future. It’s simply amazing tbh. Especially in combination with something like Apollo or an ORM like Prisma. You can also generate your schemes by using something like GraphQl nexus which will also create crud operations for you with a single line if you choose.
Wise decision. I've worked REST for years and GraphQL for around 6 months. GraphQL will never replace REST, it is not flexible enough and has too many issues without solutions
So, indeed, I was quite curious about "why all the young ones in that FB community are talking about GraphQL?" and you answered my question. I still prefer REST, though, but GraphQL can be useful for my work. So, why not both?, and let the client-writer freely choose (yep, we're not the client coder, but we supply some reference client Implementation).
3:52 *Stateless:* they don't care about the exact client to them, for example you don't see session based authentication approaches being used there, because you don't store any data about the client on the backend there, just expose those endpoints and whoever sends the right kind of request, possibly combined with some authentication logic like some attached token, whoever sends a correct request gets the data or may store some data (depending on what you expose on your api)
@@thanveershah4758 NestJS is a fairly new NodeJs framework, pretty much similar to Angular architecture. It's a good framework and thinking of using it someday, if the community grows more. Take a look into it !
Someone who has really developed a REST api wouldn't say fields are not possible to manage using it, it's actually pretty simple by using the "fields" query param
I think what you said in 6:17 might be wrong. Graphql does support GET method, it's not the most common but saying "Graphql only works with POST" is way off. So in case you want a graphql response to get cached you will have to use GET, since caching is not supported for POST method. Other then that I think the tutorial was pretty clear and helpful.
Happy Teachers day Max Bro..You are the only who teached me alot like Angular,Angular Material,Nodejs from Udemy....In Simply I want to say Thanks Max Love from India.
After almost 2 decades I wonder why people, especially ones producing tutorials and guides, still don't understand what REST really is. REST is loosly speaking just Web surfing for applications. You design the interaction between a server and a client like you'd normaly do on Web pages. Most so called REST APIs demand external documentation (Swagger, OpenAPI, ...) which a developer has to consult and hack into some code which in the end just produces some HTTP requests. In a true REST environment, however, a client indicates its capabilities through the "Accept" request header and the server will answer in a representation format supported by the client. This is summarized as content-type negotiation. The representation format itself is based on a media type that defines the syntax and semantic of messages/documents exchanged, plain JSON does neither define links nor respective elements/attributes/properties of a resource. I.e. in HTML you have all kinds of tags and the spec defines when those tags are admissible and what data they may contain and so on. A server can also use HTML to "teach" a client on what it can do next. I.e. a response may contain links and/or form sections. A link should usually be attached to a link-relation name to set the referenced resource into context to the current one. I.e. on a pageable list you might find relations such as first, next, prev and last or self to hint a client about the purpose of the link. HTML, as mentioned before, may also contain forms. Those forms not only provide a client with the necessary information on which HTTP operation to use, the target URL to send the request to and the media type the representation format sent follows, which in the case of HTML is often implicitly given as application/x-www-form-urlencoded, but it also teaches a client on the properties a resource supports. There is no need for external documentation that way at all and the form is dynamic on top. You need to add a new property to a resource? Just add it, the form will teach clients on the fly. As these support the media-type they will also know how to handle a new element/property added to a resource. One of the major problems those so called REST APIs have, is, that they use typed resources. Instead of sending the state of a resource in a representation format the client supports (after previous content-type negotiation) those APIs send out pre-defined structures of data which clients often implement directly 1:1, meaning that if anything changes in that response a client will not be able to process the response correctly. In best case the new stuff will just be ignored, in worst case the whole thing will blow up. By that, one usually should aim for a REST architecture if the server side is frequented by plenty of different ciients, especially ones not under your (direct) control. As one of the main goals of REST is the decoupling of clients and servers, adapting to changes and thus future-proof processing is inherently integrated into the overall design. For simply frontent to backend communication you don't need REST, but simply calling anything HTTP related REST is just wrong and probably the reason for the confusion so many people really have what REST is and what it isn't ...
I'm not a fun of the graphql. In Rest API you have a lot of endpoints but in graphql you have a lot of resolvers 🙃 In graphql, you have to add some additionaly work, like a graphql schema for exemple. If you want to send a data back with specific fields, you can simply select or unselect fields in your backend, you don't need a graphql to do that. In my opinion, Rest API wins.
* what is the time to set up a GraphQL server layer? * what are the performances of this GraphQL server that comes in surplus between the user, the server and the database? * what is the impact (time, manipulations) when we have to change the structure of the data? * Is there a tool to deploy automatically? All this must be taken into account, and there on the net it lacks explanations that could tilt the balance between REST and GraphQL. And I know that on the side of GraphQL it is very easy to create queries because very padlock level schema and to have a precision of data in return, these are the only advantages that I see. But to convince, we must also see the technical part of how? at what cost? and time spent?
I’m actually using PUT in my rest api where I need to filter or apply sorting or anything else. By using put, I can send filters, sorting, projection in the body, thus making it a little more readable in my opinion then sending everything as query parameters
Max, Graphql looks easy to use and have more flexibility and so on... and what about the security of the whole database when you expose such fields name of the tables? With a 'little investigation' on the source code of the app, it's look like very easy to understand the structure and make some nasty call to retrieve all database data... Am I wrong about that? Thanks
Steferson Patake from my understanding you can only query for what is exposed. So if in your database you have a user with Id name email and password you can set your query for users to o my return any field you choose and exclude the rest
With REST endpoint,function and attributes are parsed without needing to read the full body of the request. It can be done very fast and with no buffering. Then just stream the body to the correct handler. GraphQL needs to read the full JSON body before deciding what to do, and which endpoints to send. which means huge buffering issues and a very complicated handling. And all this for just a standard way to pass attributes? Would be much better to just agree on a default http attribute spec for REST and call it a day.
The argument that GraphQL's specificity allows it to get specific fields and REST does not is very disingenuous. A simple "filter" multidimensinal GET parameter can easily help you achieve that.
@@psionicronin1911 Simply implement 'filter' as a GET parameter in your API requests (that is after the url, put '?filter[specific]=record&filter[specific2]=record2'. It'll be a lot better to make it dynamic. A lot of Google APIs do this.
Example for Microsoft Project Server: /Projects ( All projects with all properties) /Projects?$filter=ProjectName eq 'ABC' (One project with all properties) /Projects?$filter=ProjectName&$select=ProjectName,ProjectId (one project with two properties) /Projects?$top=1/Tasks (First project with all of its tasks)
I'll have a look at GraphQL but to me giving the liberty of making queries from the front end complexify the permissions definition a lot. I might be wrong I still hadn't time to investigate further...
@@thanveershah4758 We're not screwed, we just have to adapt. I've been studying GraphQL. It's hard at the beginning, but it gets each time easier as you learn. It's totally worth the effort.
Correct me if I'm wrong, but authorization is part of the API system, so is a backend issue. The client just provides credentials it's credentials as usual. Also, I always thought GraphQL made front-end development easier, as you can get your data in the exact format you need from a single endpoint instead of having to merge bits and pieces from many endpoints.
I still prefer Rest... GraphQL is kind of hard to set up for a complex app, but after that is easy to use. Me personally ended up facing its restrictions over and over again when communicating with MongoDB and came to a solution were i used GraphQL and Express js mixed in the app. It is powerful but you need to learn it in depth before you want to use it believe me. :D I will learn it for sure but for now I am happy I can rely on express js any time.
Rest APIs can do everything that graphql does. Rest APIs can be programmed to accept the fields to be responded as parameters. Graphql adds more overhead and rest APIs are more extensible. No significant incentive to use graphql.
Certainly nice presentation still have a question. In graphql does it filter record for specific properties at database level or it fetches all the properties of object from database and then on server it filters columns based on query parameter? E.g. in your example graohql will bring just name and age at database level itself or at server side it will wipe out other unwanted fields?
You say graphql is only work with POST method, maybe this is wrong. I see "GraphQL HTTP server should handle the HTTP GET and POST methods" in document of graphql. And can you create a video tutorial for uploading images with Graphql that has the same progress as Axios?
I've been using GraphQL for 3 months and now I can't think to go back to REST, once you get used to do the queries and mutations, it becomes really easy to use.
I'm working in a project, and i decided to use nuxt + vue + apollo + graphql + node + express-graphql + orientdb and i really enjoy it, orientdb is a nosql graph database and i think it works too good with graphql. Graphql is more complex at the beginning but i love it, and don't think go back to REST api again.
I feel that REST API and GraphQL API are a bit like SQL and noSQL. Correct me I'm wrong, but it feels like the clarity of REST API feet well with the rigidity of SQL databases and the specificity of GrapheQL feet a lot with the flexibility of noSQL databases.
In REST you actually rarely do a POST without any Body, that does not make a lot of sense. In case of a SELECT, you would use a URL similar to the one you use. By default you would use a GET for that - where you won't be using a body but instead the URL param. I'm sorry but I dont get this slide.
I wanted to like graphql but you can't do any file uploads, you have no versioning, no caching as everything is a POST, a schema that needs to be shared with all the clients, an overly strict type system that makes sending deeply nested hashes more difficult than it needs to be and many other problems. Even the benefit of fetching less data isn't great, unless you're quering a nosql database. What happens, is that you still end up doing all the sequel queries server side, and you just save a bit of data.
@@andyl2895 It can fetch less data because GraphQL can request specific fields only, tho in REST we can still do using query parameter like /user?&fields=name,age but it adds additional complexity in backend.
Do you think graphql was made to solve the problems of http/1.1 and with h/2 it has become redundant? Fundamentally, I feel seperation of anything is better than bulk executions
Hi max, i love your video as always 👍. Do u think using apollo is better than using express graphql ? Are u planning to continue ur graphql tutorial for graphql subscriptions ?
Something funny just happened I skipped his udemy lecture on graphql to check myself do I need to learn graphql and I searched graphql vs rest API and on top this video showed😅😅 Max is everywhere😂
great video max! i have a question: if i use a specified SQL query with my REST API, wouldn’t i be able to fetch exactly the data i am looking for? im not understanding how i would be fetching more data with rest vs with graphql. thanks again
The problem is subsetting data. So having a mobile app fetch only 3 out of 12 attributes for a summary, while desktop app displays all 12. It’s difficult to write all that logic into one endpoint. The standard is to expose all data, and client would just use what it needs. Alternatively you would have to use multiple endpoints for almost the same functionality. (I am learning graphQL, take this opinion with a pinch of salt)
From a newbie stand point of view, GraphQL seems an evolution of XML Web service using Json and added some spice in the result. I know is not like the but it's looks like it. Great explanation, very clear and understandable.
You can put that logic in your resolver. Of course this is if your API Most of the time communicates to a db and have a couple of corner cases where it doesn't. If your API never uses a db, there's no point in using graphql.
GraphQL is nice tool for sure. More complex case is that calling 3rd API then access db then call 3rd API then access db. I just want to know how to solve this kind of case. This case may occur on e-payment
I'm taking your React course on Udemy right now, it's so great seeing you on so many platforms teaching and passing on your knowledge! I always find your tutorials helpful, easy to follow, and you convey concepts very succinctly.
Awesome, thank you!
I appreciated how unbiased this comparison was. I think one major thing GraphQL has going for it is that is a standardized spec. There's a lot of variation in the quality of REST APIs.
Like always. Magnificent simplicity in explaining stuff. Keep on !
So we are somewhat back at sql in the front end 😁 Everything works in cycles...
This helps to expose just needed data, as per mobile you must limit to only data needed avoiding waste of mobile data... Yet there are a server layer of control before the db, but in the end it's sql in frontend lol
Lol yes! It’s more of a generic way of storing the query columns and filter clauses, instead of having to deal with building the Rest api url (and body) dynamically.
Imo it beats rest api hands down, it may be a standard but a sucky one at that!!
Just create a config file for the GraphQl queries, to load them up and use them on your frontend, it can be managed a lot more easily than a Rest api.
This the reason Stored procedures became so useful back in the Sql dbs days! Precompiled execution plans, highly maintainable and can return sql select data as well as receive input params (sql server supported even complex inputs like xml)
Not sure why this is a versus video... since pretty sure most people use still rest api... and use graphql as a data layer (.. middleware sort of)
or am i missing something?
Was looking for you..! 😝 Who agrees that life revolves in circles. Checkout some topics which are making a comeback below
1. Server side rendering with React ( JSPs were using this)
2. Libraries are being preferred over UI framework (returning back to jQuery ? 😝)
Your thoughts would be nice 😂
Felt like i skipped a step somewhere, started web dev with plain html and css for regular static sites.. now we use gatsby and typescript to generate static sites... Is it worth it? probably not... but I get paid to do it!
I had a job interview before 2 weeks ago. And I was asked if i know what a GraphQL is, well i didn't knew cause so far i've used only Rest APIs and never had to dive in into the GraphQL, but now thanks to this 17 minutes video, I can understand the concepts behind the GraphQL and for what is used for. And I would like to thank you! All of your videos are very well structured and explained in a way that everyone can understand. I own almost all of your courses on Udemy and I learn a lot from you. Your courses are very well focused and cover lots of topics that most of the instructors are considering as "not important enough". So keep up the good work!
Здравей, Наско. Аз съм Митко, от академията на Скейлфокус. Ти ме интервюира накрая с Александър, ако се сещаш😂. Тъкмо виждам коментар от българин и виждам, че си ти😂.
@@dimitartanev97 Хах да аз съм и от време на време пиша по някое коментарче. Ти как си обадиха ли ти се oт Скейлфокус? Аз м/у другото напуснах :)
@@Devillman90 Да, разбрах... наистина жалко. Аз започнах, предполагам си изиграл роля да ме вземат 😂. Благодаря ти. Иначе, Макс има супер content. Ако не беше неговият курс за ng, нямаше да завършя академията. 😂😂
@@dimitartanev97 Да добре се справи на интервюто! Радвам, се че си започнал. Пожелавам ти много успехи в компанията! А за Макс да прави доста добри видеа малко подробни на моменти но по-добре така от колкото да остане нещо неразбрано :)
I really appreciate the precise pronunciation! Very easy to understand.
Great explanation! I've never written an API in GraphQL but now I'm inclined to do so to try it out. Thank you!
With this kind of videos from Max, huge course on the topic is on the way, I'll buy it even before he releases 🤣🤣🤣🤣.
Thanks bro, I like your teaching.
Greetings from Tanzania 🇹🇿
Please create udemy course for microservices
Uploading on youtube can help poor people like me
Yes please I would definitely buy that
@@thanveershah4758 he can do as usual, make a full course on udemy, shows the critical parts on youtube+philosophy of why we do this.
@@a.h.s.3006 Agreed
I would love to buy that!
Love this one. Thank you for the nice and short conclusion on what the difference is, between GraphQL and REST!
Greetings from Cologne!
Thanks Waldemar, happy to read that!
3rd party caching with REST is easier, like varnish or nginx, and is also possible to say witch data you want with REST API, that depends on the design you choose to go with.
You can select fields implementing ?select or ?fields query parameters with REST APi to retrieve only useful data
Great explanation of the overall purpose of GraphQL and how it fits into an application. Heard about GraphQL the other day and wanted to know what it's about.
In terms on fetching much data than needed, you can opt to use dto, convert a database entity into a simplified object to be presented on the frontend
Thank you. Nice comparation. I'm still not convinced to use GraphQL atm.
One of the biggest selling points of GraphQL for me was actually when fetching large amounts of data. With rest i would need multiple requests to different endpoint something like /users -> /users/id/comments (the last request times the number of users), where the second request has to wait for the first one to finish. But with GraphQL you can make it in one swoop and get everything you need. Also you can get data, put data, trigger a utility function, or really anything all in one request. You could literally trigger every single function and resource on the server at once.
Netrole Im sold thanks to your comment! I was wasting so much time pondering what the best method was for me to save a freshly made document, then reference the objectId for the user documents in one go but no avail. It sounds simple but I’m only in the beginning stages of my app. I know I’m going to be making a ton of more requests like that and it really just annoyed me how complex i know it would have be.
Awesome to hear there’s a solution to this :)
@@Netrole Isn't graphql doing just that? Multiple queries in the background? In an unoptimized way. Just like all those other trendy tools (webpack, react, Vue...) you just trading code speed for coding speed. Nothing wrong with that as long as you are aware of it.
@@Kiev-in-3-days If you dont run complex calculations on the server, code speed really isn't an issue. The real time killer for web apis is network latency. Having a single request instead of multiple consequtive requests saves a lot of time in network latency.
I once had a case where i was calling an api and it took 500ms to return with some ids, then i had to follow up with about 5 parallel requests with those ids, which took 300-500ms each, and then some of those requests needed another follow up request with about 400ms until i had everything i needed.
So obviously that is some pretty messy code but also pretty slow, about 1400ms. So i asked the api coder to give me an endpoint where i get everything i need in one request. A request to this endpoint took about 700ms, quiet a bit faster. So the code speed was not the major issue.
@@Kiev-in-3-days In the case described by Netrole where the client has to condition the requests and wait for data from the first request, the GraphQL design would have better performance since you don't have the network overhead. It's a pretty powerful example.
A big difficulty I faced when going for GraphQL over REST is that the complexity/unpredictability of requests makes it very hard to optimize the handling of requests. I mean, if the structure of a request just happens to not play nicely with my database schema and I didn't catch this type of request manually, GraphQL might (and many times does) handle it very inefficiently.
that just means your solution is not well planned or the package you're using for the implementation is difficult to work with. I don't mean this as an insult but here's how to go about it
Your schema is like your route description in rest right , since it basically describes what query term to use and what stuff you access to .
then Your resolver is the handler for the request it will contain the arguments.
now your revolvers should talk to a controller/controller Facade that will give it access to the resources it should expose.
this means that your resolver function doesn't have direct access for the db. hence, you just need to write controllers that will return to you resources you expect in the revolvers. So even having complex nested schema definitions will still be resolved quite easily in this approach since each sub nesting or a resource mutually exclusive from the schema definition can still be mapped in this regards.
now , for the package you should use , if you're using graphQL in node , then i would highly highly recommend graphQL-js.
github.com/graphql/graphql-js , as it will take the pain and suffering caused by sdl and make it baked into the framework itself.
@@abeplus7352 Abe Plus tanks for the detailed response. It may very well be that my implementation approach wasn't well thought out. I was just testing GraphQL on Django with Django Rest Framework. Loved it on the client side. I'll definitely give it another try as soon as I get my hands on a project that could benefit from its features.
Thanks for the video, I had no idea what GraphQL was now I have an intro and I think I'll be sticking with REST.
FangerZero Graphql is the future. It’s simply amazing tbh. Especially in combination with something like Apollo or an ORM like Prisma. You can also generate your schemes by using something like GraphQl nexus which will also create crud operations for you with a single line if you choose.
Wise decision. I've worked REST for years and GraphQL for around 6 months. GraphQL will never replace REST, it is not flexible enough and has too many issues without solutions
REST for microservice communications or gRPC and JSON:API for modern front-ends instead of GraphQL ;)
So, indeed, I was quite curious about "why all the young ones in that FB community are talking about GraphQL?" and you answered my question. I still prefer REST, though, but GraphQL can be useful for my work. So, why not both?, and let the client-writer freely choose (yep, we're not the client coder, but we supply some reference client Implementation).
Hello Max! Could you add a bonus section of GraphQL in your React Complete Guide course in Udemy? It would be wonderful! Thanks!
I second that
3:52 *Stateless:* they don't care about the exact client to them, for example you don't see session based authentication approaches being used there, because you don't store any data about the client on the backend there, just expose those endpoints and whoever sends the right kind of request, possibly combined with some authentication logic like some attached token, whoever sends a correct request gets the data or may store some data (depending on what you expose on your api)
I would suggest a course of Nest.js + GraphQL + Websockets = Take all my money :)
What is Nest ? Is it same as Next.js ?
This should be helpful => academind.com/learn/node-js/nestjs-introduction/
@@thanveershah4758 NestJS is a fairly new NodeJs framework, pretty much similar to Angular architecture. It's a good framework and thinking of using it someday, if the community grows more. Take a look into it !
go check hasura
This was exactly what I needed. Thank you good sir.
Happy to read that the video was helpful, thanks a lot for your comment!
Someone who has really developed a REST api wouldn't say fields are not possible to manage using it, it's actually pretty simple by using the "fields" query param
I think what you said in 6:17 might be wrong. Graphql does support GET method, it's not the most common but saying "Graphql only works with POST" is way off. So in case you want a graphql response to get cached you will have to use GET, since caching is not supported for POST method. Other then that I think the tutorial was pretty clear and helpful.
Happy Teachers day Max Bro..You are the only who teached me alot like Angular,Angular Material,Nodejs from Udemy....In Simply I want to say Thanks Max Love from India.
Thanks so much Md, greetings from Germany :)
genuinely love you Max. you're the best! Currently taking your Flutter Udemy course and its first class as all your content. Keep up the great work!
Thanks a lot for your support Harun, happy to read that you like the course!
@@academind I 2 lv u and brad.
After almost 2 decades I wonder why people, especially ones producing tutorials and guides, still don't understand what REST really is. REST is loosly speaking just Web surfing for applications. You design the interaction between a server and a client like you'd normaly do on Web pages.
Most so called REST APIs demand external documentation (Swagger, OpenAPI, ...) which a developer has to consult and hack into some code which in the end just produces some HTTP requests. In a true REST environment, however, a client indicates its capabilities through the "Accept" request header and the server will answer in a representation format supported by the client. This is summarized as content-type negotiation.
The representation format itself is based on a media type that defines the syntax and semantic of messages/documents exchanged, plain JSON does neither define links nor respective elements/attributes/properties of a resource. I.e. in HTML you have all kinds of tags and the spec defines when those tags are admissible and what data they may contain and so on. A server can also use HTML to "teach" a client on what it can do next. I.e. a response may contain links and/or form sections. A link should usually be attached to a link-relation name to set the referenced resource into context to the current one. I.e. on a pageable list you might find relations such as first, next, prev and last or self to hint a client about the purpose of the link.
HTML, as mentioned before, may also contain forms. Those forms not only provide a client with the necessary information on which HTTP operation to use, the target URL to send the request to and the media type the representation format sent follows, which in the case of HTML is often implicitly given as application/x-www-form-urlencoded, but it also teaches a client on the properties a resource supports. There is no need for external documentation that way at all and the form is dynamic on top. You need to add a new property to a resource? Just add it, the form will teach clients on the fly. As these support the media-type they will also know how to handle a new element/property added to a resource.
One of the major problems those so called REST APIs have, is, that they use typed resources. Instead of sending the state of a resource in a representation format the client supports (after previous content-type negotiation) those APIs send out pre-defined structures of data which clients often implement directly 1:1, meaning that if anything changes in that response a client will not be able to process the response correctly. In best case the new stuff will just be ignored, in worst case the whole thing will blow up.
By that, one usually should aim for a REST architecture if the server side is frequented by plenty of different ciients, especially ones not under your (direct) control. As one of the main goals of REST is the decoupling of clients and servers, adapting to changes and thus future-proof processing is inherently integrated into the overall design. For simply frontent to backend communication you don't need REST, but simply calling anything HTTP related REST is just wrong and probably the reason for the confusion so many people really have what REST is and what it isn't ...
I'm not a fun of the graphql. In Rest API you have a lot of endpoints but in graphql you have a lot of resolvers 🙃 In graphql, you have to add some additionaly work, like a graphql schema for exemple. If you want to send a data back with specific fields, you can simply select or unselect fields in your backend, you don't need a graphql to do that. In my opinion, Rest API wins.
fantastic. Could you make a video about the differences between graphQL and OData ?
What about gRPC and gRPC-Web? Thank you Max.
Max is really making this CS stuff very understandable. Thank you Max!!!
* what is the time to set up a GraphQL server layer?
* what are the performances of this GraphQL server that comes in surplus between the user, the server and the database?
* what is the impact (time, manipulations) when we have to change the structure of the data?
* Is there a tool to deploy automatically?
All this must be taken into account, and there on the net it lacks explanations that could tilt the balance between REST and GraphQL.
And I know that on the side of GraphQL it is very easy to create queries because very padlock level schema and to have a precision of data in return, these are the only advantages that I see.
But to convince, we must also see the technical part of how? at what cost? and time spent?
I’m actually using PUT in my rest api where I need to filter or apply sorting or anything else. By using put, I can send filters, sorting, projection in the body, thus making it a little more readable in my opinion then sending everything as query parameters
That's bad practice. When you use GET you are sure nothing will be changed after the request. With PUT it's all different.
Hi Max, what do you think about OData (compared to GraphQL)?
Owhat? never even heard of... :D need to look into it.
Great video, thanks!
The more I learn and work with graphQL, the more genious I find it.
Max, Graphql looks easy to use and have more flexibility and so on... and what about the security of the whole database when you expose such fields name of the tables? With a 'little investigation' on the source code of the app, it's look like very easy to understand the structure and make some nasty call to retrieve all database data... Am I wrong about that? Thanks
you have to define boundaries, limitations, aliases etc.
Steferson Patake from my understanding you can only query for what is exposed. So if in your database you have a user with Id name email and password you can set your query for users to o my return any field you choose and exclude the rest
With REST endpoint,function and attributes are parsed without needing to read the full body of the request. It can be done very fast and with no buffering. Then just stream the body to the correct handler.
GraphQL needs to read the full JSON body before deciding what to do, and which endpoints to send. which means huge buffering issues and a very complicated handling.
And all this for just a standard way to pass attributes?
Would be much better to just agree on a default http attribute spec for REST and call it a day.
My concern which I have been researching and yet to hear is security 🤔 how can we secure graphQL data qeiuries, what are the vulnerabilities ?
The argument that GraphQL's specificity allows it to get specific fields and REST does not is very disingenuous. A simple "filter" multidimensinal GET parameter can easily help you achieve that.
I've been trying to tell people this and they aren't getting it.
Take OData for instance, it implements exactly that with $filter and $select
This sounds interesting, got an example of this I could see?
@@psionicronin1911 Simply implement 'filter' as a GET parameter in your API requests (that is after the url, put '?filter[specific]=record&filter[specific2]=record2'.
It'll be a lot better to make it dynamic. A lot of Google APIs do this.
Example for Microsoft Project Server: /Projects ( All projects with all properties) /Projects?$filter=ProjectName eq 'ABC' (One project with all properties) /Projects?$filter=ProjectName&$select=ProjectName,ProjectId (one project with two properties) /Projects?$top=1/Tasks (First project with all of its tasks)
I'll have a look at GraphQL but to me giving the liberty of making queries from the front end complexify the permissions definition a lot. I might be wrong I still hadn't time to investigate further...
Yeah , We are screwed as a Front End Engineers
@@thanveershah4758 We're not screwed, we just have to adapt. I've been studying GraphQL. It's hard at the beginning, but it gets each time easier as you learn. It's totally worth the effort.
Correct me if I'm wrong, but authorization is part of the API system, so is a backend issue. The client just provides credentials it's credentials as usual.
Also, I always thought GraphQL made front-end development easier, as you can get your data in the exact format you need from a single endpoint instead of having to merge bits and pieces from many endpoints.
@@romulloqueiroz I can only use GraphQL in the front end if they have used it in the Backend right ?
@@thanveershah4758 Yes. Someone creates the api on the backend, so you call that api on the frontend.
As always great explanations. Thank you Max🌹
I still prefer Rest... GraphQL is kind of hard to set up for a complex app, but after that is easy to use. Me personally ended up facing its restrictions over and over again when communicating with MongoDB and came to a solution were i used GraphQL and Express js mixed in the app. It is powerful but you need to learn it in depth before you want to use it believe me. :D I will learn it for sure but for now I am happy I can rely on express js any time.
Rest APIs can do everything that graphql does. Rest APIs can be programmed to accept the fields to be responded as parameters. Graphql adds more overhead and rest APIs are more extensible. No significant incentive to use graphql.
query as data and not URL? Then it has nothing to do with REST. It is almost like people have already forgot SOAP.
Tibor Digaňa it seems so really :)
@@asanokatana SOAP is useful when you want to call the end point to "do something". The REST is useful to "get something".
Certainly nice presentation still have a question. In graphql does it filter record for specific properties at database level or it fetches all the properties of object from database and then on server it filters columns based on query parameter? E.g. in your example graohql will bring just name and age at database level itself or at server side it will wipe out other unwanted fields?
So so good! Thank you for making this content!
What's missed is that a major advantage of REST api's is that the requests can be cached. Not true with GraphQL queries.
Can't you basically use post only for your rest api and have your own query language in the json body.
Hello Max,
What is your next course on Udemy?
We'll share some news in the next weeks :)
@@academind Waiting for the next week
You say graphql is only work with POST method, maybe this is wrong. I see "GraphQL HTTP server should handle the HTTP GET and POST methods" in document of graphql. And can you create a video tutorial for uploading images with Graphql that has the same progress as Axios?
academind successfully made me a better web developer
I've been using GraphQL for 3 months and now I can't think to go back to REST, once you get used to do the queries and mutations, it becomes really easy to use.
Thanks Max! By the way I wish that you and your team make a course about headless cms or e-commerce with Hugo! Greetings from Costa Rica!
Sorry, currently we got no plans regarding such a course, but this can always change. Greetings from Germany :)
Academind thanks for the quick response, no problem I’ll continue to learning it by my own 😊
This was very useful. Now I understand where and when I would want to use GraphQL over REST. Thanks Max!
Happy to read that, thanks a lot!
I got my eye on Maximilian's Air Max 90s... ;)
Danke schoen... great work as always!
We can use FaunaDB which support GraphQL natively.
I'm working in a project, and i decided to use nuxt + vue + apollo + graphql + node + express-graphql + orientdb and i really enjoy it, orientdb is a nosql graph database and i think it works too good with graphql. Graphql is more complex at the beginning but i love it, and don't think go back to REST api again.
Concise and to the mark. Amazing content! Thanks mate
Thank you Yash!
Greetings, Can you prepare a video tutorial about installing pure php with GraphQL?
thanks for this introduction into GraphQL!
I feel that REST API and GraphQL API are a bit like SQL and noSQL. Correct me I'm wrong, but it feels like the clarity of REST API feet well with the rigidity of SQL databases and the specificity of GrapheQL feet a lot with the flexibility of noSQL databases.
hello mr Max. you are one the best Teacher in the world , I have never seen anyone like as you. teach at Harvard university. 👍👍👍
Wow, thank you so much for this amazing feedback John, this means a lot to me!
Another great video Max! Excellent work.
Your projects are so useful & perfect👍👍
In REST you actually rarely do a POST without any Body, that does not make a lot of sense. In case of a SELECT, you would use a URL similar to the one you use. By default you would use a GET for that - where you won't be using a body but instead the URL param. I'm sorry but I dont get this slide.
Watching you in any Speed below 1.5x is just weird for me ahahahaha Love the course bro
I’m a fan of Neo4j + GraphQL
Thanks for a great video. I just started learning Web Services & APIs in my Bootcamp and this is a great help.
Happy to read that, thank you!
I wanted to like graphql but you can't do any file uploads, you have no versioning, no caching as everything is a POST, a schema that needs to be shared with all the clients, an overly strict type system that makes sending deeply nested hashes more difficult than it needs to be and many other problems.
Even the benefit of fetching less data isn't great, unless you're quering a nosql database. What happens, is that you still end up doing all the sequel queries server side, and you just save a bit of data.
I dont see how graphQL is able to fetch less data than for example an OData REST query
@@andyl2895 It can fetch less data because GraphQL can request specific fields only, tho in REST we can still do using query parameter like /user?&fields=name,age but it adds additional complexity in backend.
@@lattelover7186 OData has it built in, and I can't think how GraphQL doesn't have to implement it in the backend
You can always filter returned data.
@@lattelover7186 GraphQL adds more complexity and overhead than REST anyway
Beautiful video, great explanation!
Do you think graphql was made to solve the problems of http/1.1 and with h/2 it has become redundant? Fundamentally, I feel seperation of anything is better than bulk executions
I love how he says also instead of also
So by less data transferred when graphql it mean less columns of data , right?
Hi max, i love your video as always 👍. Do u think using apollo is better than using express graphql ? Are u planning to continue ur graphql tutorial for graphql subscriptions ?
Isn't it OData vs GraphQL?
YES! Or Web API vs GraphQL. GraphQL is built over RESTfull concepts, as the Web API is. Many people don't get that.
Wonderful Job!! Thank so much!
I hope you will build a serie on graphQL with Prisma2! I propose vue.js as frontend if you do :)
This is very helpful for me to understand why I have to go for GraphQL. Thanks 🙏🙇
HI Max, @10:02 you refer to a video, where can I find it as the link is not in the description
Please explain how to create documentation like swagger in GraphQL. I don't know how to implement it. It's not straight forward in GraphQL.
Something funny just happened
I skipped his udemy lecture on graphql to check myself do I need to learn graphql and I searched graphql vs rest API and on top this video showed😅😅
Max is everywhere😂
SOmething is missing here . A REST architecture should be explained and then the follow up . Thanks
great video max! i have a question: if i use a specified SQL query with my REST API, wouldn’t i be able to fetch exactly the data i am looking for? im not understanding how i would be fetching more data with rest vs with graphql. thanks again
The problem is subsetting data. So having a mobile app fetch only 3 out of 12 attributes for a summary, while desktop app displays all 12. It’s difficult to write all that logic into one endpoint. The standard is to expose all data, and client would just use what it needs. Alternatively you would have to use multiple endpoints for almost the same functionality. (I am learning graphQL, take this opinion with a pinch of salt)
From a newbie stand point of view, GraphQL seems an evolution of XML Web service using Json and added some spice in the result. I know is not like the but it's looks like it. Great explanation, very clear and understandable.
Very good overview!
Your explanation was so clear , thank u sir 👊🏽
Answer = REST. GraphQL is a half cooked solution riddled with problems.
I'd like to get this presentation that you used in the video
Great explanation, thanks Max!
Great video! Your videos are really helpful. thank you!
What do you thing about angular/ionic with AWS amplify and AWS Appsync ? It seems very powerfull to manage graphql. Greetings from Belgium
this is perfect. thank you so much
Thank you...I am in step to do GraphQL...
Thank you for the tutorial sir. But i still couldn't understand whats the advantage of graphql.. It is not solving a problem
Unrelated question about the topic. What is that weird 8 statue behind you?
or you can use REST API with ODATA that way you can use GET,POST,PUT and DELETE along with the fancy ass querying
How about the case API does not access db?
Something like call 3rd party api.
Something is resource accessing but not db?
You can put that logic in your resolver. Of course this is if your API Most of the time communicates to a db and have a couple of corner cases where it doesn't. If your API never uses a db, there's no point in using graphql.
GraphQL is nice tool for sure. More complex case is that calling 3rd API then access db then call 3rd API then access db.
I just want to know how to solve this kind of case.
This case may occur on e-payment
Great! Can we have Angular with GraphQL and backend as NestJs course on Udemy?
Nest + Graphql would be awesome
Max is the best in teaching! Not more to say!