GraphQL vs REST: Which is Better for APIs?

  Переглядів 177,713

IBM Technology

IBM Technology

Рік тому

Create, manage, secure, socialize and monetize APIs with IBM API Connect → www.ibm.com/products/api-connect
What is a REST API? → ibm.biz/what-is-REST
If you're a developer, you're probably familiar with REST APIs, but there's another query language for APIs that you should add to your programming toolkit: GraphQL. In this video, Martin explains the two different approaches these frameworks take for building APIs and compares their strengths and weaknesses. Spoiler alert: It's not an either/or choice, and it's worth knowing both approaches and applying them where it makes the most sense.
Read SmartPaper to learn how to unlock the full potential of your APIs → ibm.biz/BdMpX6
Sign up for a live demo of API Connect, IBM's API management solution → ibm.biz/BdMpXU
Try IBM API Connect free for 30 days → ibm.biz/BdMpX5
#restapi #graphql #query

КОМЕНТАРІ: 114
@InfoSecGSO
@InfoSecGSO 7 місяців тому
I've got to say, that not only is this is the best breakdown of REST vs GraphQL that I've come across, but also, the best high-level overview /explanation of GraphQL in a concise context.
@donaldduck682
@donaldduck682 Рік тому
It would be really great to hear pros and cons of each as well. Would appreciate it if you can provide that info too.
@Steven26789
@Steven26789 8 місяців тому
Best simplified explanation
@MrThurobrand
@MrThurobrand Рік тому
I enjoy your Brewlosophy videos as well as these. Keep up the good work.
@htk0002
@htk0002 Рік тому
GraphQL simplifies API building because you don't have to create custom endpoints for every single scenario. You just define the schema and thats it, you can query what ever you want. Imagine you're building a house, and you need to order materials from different suppliers. With REST, you'd have to order each material separately, and each supplier would give you a fixed set of materials, regardless of whether you need them all or not. With GraphQL, you can specify exactly which materials you need, and each supplier will only give you what you asked for, reducing waste and improving efficiency.
@dhruvangdave3695
@dhruvangdave3695 11 місяців тому
But it won't be more reliable use in such applications where we want full controller over what details we are providing... For that Rest will be more suitable.
@jasper5016
@jasper5016 8 місяців тому
Your explanation is lot better than this IBM guy
@charlesclayman3909
@charlesclayman3909 7 місяців тому
Your explanation is much clearer. Thanks
@elijahmalewo1683
@elijahmalewo1683 6 місяців тому
You forgot about costs graphql is expensive to maintain
@midophriya3657
@midophriya3657 12 днів тому
if you want to REST api same as GraphQL fetch, you have to create a request with data sql in it. ofcourse, it is not safe but you have to filter the sql. drop, delete, update, insert and etc are not allowed.. only select will allowed.
@amsimun
@amsimun Рік тому
thank you for that helpful comparison.. to my understanding REST is also Protokoll agnostic.. despite probably beeing widely implemented on HTTP
@valerielampkin7718
@valerielampkin7718 Рік тому
Martin, Excellent video as always!
@paultaylor9963
@paultaylor9963 Рік тому
The final project in my bootcamp involved working with GraphQL. I could definitely see the benefits and enjoyed working with it, but it was probably overkill for what I was doing at the time.
@MaulikParmar210
@MaulikParmar210 Рік тому
Until you start with existing rest tooling and enormous support in almost every stack, graphql seems like a dream that doesn't come true when it comes to practical solutions. For starters, FB, where it originated, took more than 5 years to transition and few more until it became mature. But then they always have mutating endpoints effectively against fixed schema philosophy. No framework is perfect!
@tyronefrielinghaus3467
@tyronefrielinghaus3467 Рік тому
This guy is my favourite IBM presenter....by far . This one was good.
@ptdive
@ptdive Рік тому
And he is also a beer expert!
@jstevh
@jstevh Рік тому
Thanks! Caught me up. When was paid to code in ancient times was arrival of XML was the big deal. I love XML. Now got info on the new stuff. Ok.
@AmmarTheTrainer
@AmmarTheTrainer 3 місяці тому
Best explanation for REST vs GraphQL
@jaimedan2358
@jaimedan2358 Рік тому
Thanks a lot for this clarification.
@antonivashchyk2021
@antonivashchyk2021 Рік тому
That moment when you've known Martin as a beer bowler for several years and now realize he is a software engineer 😁. Thank you for the good explanation!
@pharmajoe990
@pharmajoe990 Рік тому
I thought I recognised him 😂
@olafschermann1592
@olafschermann1592 Рік тому
Does GraphQL add possible risks like possible high server load or a kind of SQL injection? What about schema changes, is there a versi9ning?
@smrutikantnayak3652
@smrutikantnayak3652 5 місяців тому
Hey Mate thank you for this lesson. If we consider the performances of both REST and GRAPHQL, which is faster in terms of providing responses if we aren't worried about network call latency. If I understood correctly that graphQl is another layer that we are adding after fetching data from the sources. I mean we are adding probably a presentation layer inside the logic before passing the response data to the client. I know thats the requirement of the client, but can't we achieve the same in REST? Or we should only and only consider GRAPHQL in case where we have to collect data from various sources and bring it to be in a desired format that the client needed?
@sreekanth850
@sreekanth850 Рік тому
With exact paylod or query string i can get precise output data from a rest endpoint. So why should i go for graph ql with 10x overhead of implementation and maintenance?
@nicklaspillay7923
@nicklaspillay7923 4 місяці тому
Excellent video, I really like the side by side comparison, no idea how that works (writing on a board while facing a camera) 😂
@awakenwithoutcoffee
@awakenwithoutcoffee Місяць тому
thank you for the best explanation so far :)
@ifeanyiilonze5485
@ifeanyiilonze5485 11 місяців тому
I don't see anything fancy about graphql. Cos with with rest, you can still return the specific data the client wants. It all boils down to how you write your code
@julienwickramatunga7338
@julienwickramatunga7338 Рік тому
Nicely explained, thank you very much!
@thomaspotterdotexe
@thomaspotterdotexe Рік тому
My gosh love your explanation, now I clearly get the idea of graphql is
@shubhamdas6519
@shubhamdas6519 2 місяці тому
Thanks for the video sir....
@axelrod-_-
@axelrod-_- Рік тому
really good explain
@user-hw4td5zc1g
@user-hw4td5zc1g 9 місяців тому
ok i have a question what if the user contains millions of data and you fetch data only in 1 request i think thats bad practice we only want to use pagination for requesting another data when the user scrolls infinitescrolling
@LawZist
@LawZist Рік тому
Very clear explanation. Thanks
@MasayaShida
@MasayaShida Рік тому
My beginner brain can understand this. Thank you!
@peterdo4652
@peterdo4652 11 місяців тому
Oh man, hello Cambodia friend from Vietnam, your video you sing Final Masquerade is awesome 👍
@ErikWillekens
@ErikWillekens 6 місяців тому
It is hard to understand the downsides of GraphQL aside from it's complexity - The question I have though is if it is suitable if you have a complex set of interrelated tables which are organised in a sql database yet follow the structure of graphs.
@Stopinvadingmyhardware
@Stopinvadingmyhardware Рік тому
I solved the file formatting problem, as well as the transport and communications issues. Just waiting to commit to code.
@vengateshvaidyanathang550
@vengateshvaidyanathang550 Рік тому
Can we expect video related to how to use graphQL using as wrapper on Rest in future
@ramdafale
@ramdafale Рік тому
I had that implementation in my project. We have created wrapper over rest using graphql
@dirkp.6181
@dirkp.6181 Рік тому
Honestly I doubt that this makes sense. To hide REST under GraphQL leaves all possible disadvantages of REST in the given solution. GraphQL is not and never was a _replacement_ or _successor_ of REST. As said, the GraphQL layer would have to deal with possible disadvantages and could not play its strengths. If used as integration layer over some/many REST APIs, over-fetching issues and lack of filtering and other stuff cannot be vanished and therefore remain. What you want to "wrap" is your data model or data source - even though I wouldn't exactly call it "wrap", but "access".
@SpinnedRock
@SpinnedRock Рік тому
Any examples of an API management tool? Either for G / R 😉 currently using Postman ...
@allanbengco670
@allanbengco670 Рік тому
When using AWS as a backend, Appsync would be the API service for graphQL.
@pankaj16octdogra
@pankaj16octdogra Рік тому
Pls also explain grpc and message que technologies
@rjwhite4424
@rjwhite4424 4 місяці тому
Can't you prevent over fetching by passing in query params?
@SamWestonJ
@SamWestonJ 6 місяців тому
from my reading of the graphql docs, blog explanations, and now youtube presentations, i guess you do get a single endpoint, but the server still needs to talk to every data source to combine and return relevant results. i'm not sure how this necessarily makes anything easier than just writing a well thought out REST API. Complex data appears pretty expensive to implement with graphql, unless I'm misunderstanding everything I just got done reading, whereas you can just combine and filter those resources with REST in a pretty straightforward fashion.
@shriramsakthivel2851
@shriramsakthivel2851 Місяць тому
Exactly this is what Im thinking of right now. Im just getting started with graphql, created a REST api server and implemented a layer of graphql on top of it. I think so, there may be some more features or so associated with graphql🤔🤷🏻, as companies like netflix, facebook, etc., are using graphql. Just I wish somebody could get me up with the leverage of using graphql
@WilliamShrek
@WilliamShrek Рік тому
So you can write with your left hand and also from right to left?
@spyroninja
@spyroninja Рік тому
No, they just mirror the video
@ifeanyiilonze5485
@ifeanyiilonze5485 11 місяців тому
For instance, if you need to retrieve name and age from a database using rest, you simply fetch data from a data source that has a lot of fields in them including the name and age and all you have to do is extract the name and age from it
@ryanshannon7703
@ryanshannon7703 10 місяців тому
I've worked at companies that do this and I got paid *A LOT* to optimize their application. "Oh, you're retrieving 50+ columns because the UI needs these 4 columns? STOP DOING THAT!" I learned quite a bit from that company and their methodology, though, so that was great skill builder for me. Now that I'm elsewhere and we're planning on integrating multiple business units into an uniform GUI, I'm definitely interested in pursuing this. There were countless times where over 1 gig of data was being retrieved just to pare it down to maybe 20 or 30 MB for the result set on the UI.
@rizkygabriel7587
@rizkygabriel7587 17 днів тому
Please make a video about REST vs WebSocket.
@RichardNeswold
@RichardNeswold Рік тому
He didn't mention GraphQL subscriptions. How does REST provide a stream of data?
@whilechannel
@whilechannel Рік тому
GraphQL uses websockets under the hood for subscriptions. GraphQL dis not invent anything, websockets is just http
@saadisave
@saadisave Рік тому
WebSocketUpgrade
@davidmurphy563
@davidmurphy563 Місяць тому
Ugh, I gave up on making a GraphQL query earlier this week - was trying to get httpx to log into a website - had it been rest I'd have done it in ten minutes. But that's my lack of familiarity with it and the fact I don't have access to the schema - just the request in my browser. I get the reasoning but I found it a pain.
@Meleeman011
@Meleeman011 6 місяців тому
why not just take the complex data, put them into services and turn it into one rest api endpoint?
@Chatbot121
@Chatbot121 5 місяців тому
is GraphQL more performant?
@zickzack987
@zickzack987 Рік тому
That was a comparison btw http crud and gql. Have not seen any rest.
@bekazandukeli7451
@bekazandukeli7451 Рік тому
Can somebody explain how his vide was shot?
@timovanasten
@timovanasten Рік тому
camera -> glass -> presenter Presenter writes normally on the glass, so on the footage the writing is mirrored. Then during editing, we can mirror the footage again so the viewers can read it
@hitmanvivek
@hitmanvivek Рік тому
Can we say oDATA sites between REST and GraphQL.?
@dirkp.6181
@dirkp.6181 Рік тому
Probably not exactly. It tried to cope with some shortcomings of REST, while also seeming to sacrifice some REST foundations, right?
@vaibhavgupta7429
@vaibhavgupta7429 Рік тому
I dont understand this advantage of having a schema and getting only the required information in graphql, we can also get the same benefit in REST APIs by using query parameters isnt it or I am missing something
@clivejefferies
@clivejefferies Рік тому
My guess would be scalability and also the fact, that you can get data from multiple places and merge them together. Rest would require multiple requests. He does mention this
@chaybislam
@chaybislam Рік тому
It solve the peoblem of overfetching, if you fetch from a movies api for example you don't need the production company the date of release, you need just the name and actors.
@Cysecsg
@Cysecsg Рік тому
@@chaybislam This can be solved by rest api too
@TheDolmant
@TheDolmant Рік тому
These are just two different ways of querying and updating information, neither gives you more functionality. As with any form of schema or framework they make certain things easier and other things harder. In graphql for example it is extremely difficult to debug and optimise the performance of a complex query, whereas in REST it is harder to do complex queries like optionally fetching related data, batching requests or providing computed properties. You need to decide what you care about. I HIGHLY value simplicity and in my opinion anything that adds another interface to communication needs to have enormous benefits to compensate. Personally I am not a fan of graphql because I dont think it has many benefits and most of the problems it solves (like overfetching) were not high on my list of concerns to start with.
@fuhoo5836
@fuhoo5836 Рік тому
the "multiple requests" comment is nonsense. you can manually make an endpoint that combines data across multiple sources and still call it restful. graphql is for frontend engineers who want to pretend that they are fullstack engineers.
@hmlchy
@hmlchy Рік тому
As an automation/integration dev, I love Rest over Graph, graph increases unnecessary development time for the end user imo. Also Rest is just easier to understand looking at the documentation. However, graph is efficient for the platform, that's why large corporations are embracing it.
@dirkp.6181
@dirkp.6181 Рік тому
That seems to be an under-complex view of the problem. If one's working with rather simpler models and clients where over-fetching is not a problem for whatever reasons, REST maybe fine. However, if it comes to complex data structures and manifold requests over the schema, GraphQL comes to rescue. Besides traversing the schema, already simple operations like client side sorting, filtering, paging are not natively supported and honestly pain in the ass problems with REST to solve, while leading "out of" REST. HATEOAS can give hints for traversing a schema, but the other problems remain and HATEOAS not only increases client comfort, but also the amount of response data. Btw, never was the question to rate one over the other as they serve (almost completely) different purposes and goals.
@cleric4933
@cleric4933 9 місяців тому
I know this channel has the authority of IBM themselves, but the moment an instructor says "Liberries" all credentials are off the table. 4:15
@Stopinvadingmyhardware
@Stopinvadingmyhardware Рік тому
Yes, it only took me two days.
@olafschermann1592
@olafschermann1592 Рік тому
How does OData play along? Isn’t that a way to query the restful http get request?
@ericbersan6557
@ericbersan6557 7 місяців тому
pls someone tells my how is he writing on the board
@IBMTechnology
@IBMTechnology 7 місяців тому
See ibm.biz/write-backwards
@neel75
@neel75 Рік тому
the person is left handed or right handed?
@IBMTechnology
@IBMTechnology Рік тому
See ibm.biz/write-backwards
@Jabberwockybird
@Jabberwockybird 3 дні тому
rest (json apis) vs GraphQL (or falcor, lol) vs REST (actual rest with hypermedia). Poor hypermedia, it doesn't even get to be in the discussion and it's the best option
@segus_faultise
@segus_faultise Рік тому
BIg ups
@drivebuss8079
@drivebuss8079 Рік тому
any chance I get a job in your company
@VaibhavSharma-zj4gk
@VaibhavSharma-zj4gk Рік тому
hi is he writting backwards?
@rkalla
@rkalla Рік тому
Timo responded in another comment, the video is likely mirrored before uploading so everything looks right to us.
@chswin
@chswin Рік тому
You can bury graphQL with odata both promise a simplistic interface to the consumer with increasing complexity on the backend.. by time you organize your data, indexes and provide an authorization layer it become a jumbled mess…
@Glicerol
@Glicerol Рік тому
Graphql schema is difficult to maintain with a lot of repetition for input and output types, it is an interesting idea but very poorly implemented. And actually, with the REST you can achieve the same effect using query parameters, so no real benefits ;)
@Dmytro-kt3fr
@Dmytro-kt3fr Рік тому
it depends. I m trying the hasura graphql to get rid of maintenance actually and simplify(almost get rid of) the cross department communication. We have a need in general data access api for the gold layer of deltalake architecture. And sql endpoints to databricks are crazy money, writing apis is hell (cos no reqs, no people, no time) and its almost perfect If money for non direct costs (infra maintenance, dev efforts, lack adequate product and fe reqs, tons of stakeholders that do not want to talk, rapid dev needed) are much larger then cost of pure scaling of solution - it may be a wise option I liked the hasura concept, because you have cruds autogenerated, you have explain for each request and things like filters, sorts and pagination are done ad hoc. Thing that were previously weeks of wait are now minutes. If you have smth more complex - just write sql and back it up with gql endpoint. You need expose rest instead of gql - 2 click here you go. New db - here you have an api in a min. Need smth fully customized - fApp and proxy through hasura. No crazy estimates for things that can be done in a minutes. We got quite a nice result with hasura+cosmos for pgsql(hyperscale azure or citus). But price is not for startups.
@simonsimonian8306
@simonsimonian8306 Рік тому
Amen to that! With restful ODATA, you can pretty much get the data you want filtered the way you want.
@vilkazz
@vilkazz Рік тому
Latest iteration of the schema spec do include interfaces that you can also apply in the federation mode, thus the repetition can be contained IF the backend under is composable.
@boniedwin
@boniedwin Рік тому
agree, graphql also just ignore anything about REST (PUT, POST, GET) in favour of just using POST, and it's only return http status code 200
@dirkp.6181
@dirkp.6181 Рік тому
@@simonsimonian8306 ODATA isn't REST anymore.
@nireshmaharaj2682
@nireshmaharaj2682 Рік тому
GraphQL adds an unnecessary level of complexity to applications which will require more time and effort when it comes to debugging. Also, it consumes more resources on the server than a REST API so it won't be suitable for a company internal server because all of the network clients connecting to it are sitting idle and can do the query processing instead. From an energy efficiency point of view, it's not suitable for data centers either because again the clients are sitting idle, consuming the same power but not doing the processing locally (which may actually be faster, depending on the server load). With local caching, the strain on network resources will also be diminished although that's hardly a consideration with today's bandwidth, but still worth considering for energy efficiency.
@felipechaves6100
@felipechaves6100 Рік тому
GraphQL will only require more effort to debugging if the application is highly complex or the team is not experienced in the technology. What do you mean by it expending more resources in the server? 🤔 And what you mean about the clients sitting idle? How’s that different from REST? Imo you should use graphQL when you have complex queries and/or multiple data sources, it’s also good for mobile applications where bandwidth is a concern. You do lose on HTTP cache tho, so you need to test if the bandwidth gain is worth it or not.
@dirkp.6181
@dirkp.6181 Рік тому
@Niresh Maharaj: As explained earlier, this explanation is completely wrong and expresses a fundamental lack of understanding, what GraphQL is, what the conceptional differences to REST are and where and when either of these have their advantages. Never was either of these meant as replacement or successor of the other and therefore treating them a just interchangeable, as the comment implies, is plain wrong. Btw, also the assumptions drawn considering "efficiency" in different aspects are "pseudo-clever", seem overly generalized, weird and misleading. - Think yourself: Facebook only introduced and still uses GraphQL to heat up their server farms?! Others do so too... Sorry to be so straight, but the comment is in almost ever aspect nonsense!
@MarcosMelo-dr3pb
@MarcosMelo-dr3pb 7 місяців тому
Does anyone noticed that he had to write everything backwards?
@iko089
@iko089 7 місяців тому
my g
@pusabodhisattva2183
@pusabodhisattva2183 6 місяців тому
recently, I applied to IBM for an engineering job. They sent me a personality test, trying to test whether my personality is good to fit into IBM. So either they think some personalities are not good, or that people can't fake an answer they want to see. I now see the person in this video, having a good personality.
@stevenstone307
@stevenstone307 3 місяці тому
Hey doesn't this guy make beer?
@nikhiltokas4206
@nikhiltokas4206 7 місяців тому
Bro is writing in the opposite direction while explaining complex code terminologies. Nice.
@benjaminhon86
@benjaminhon86 Рік тому
The more I use gql the more I hate it. It is only good for 1 use case that that is only READ list of dicts. Should never even do mutation in GQL
@BERTDELASPEED
@BERTDELASPEED 10 місяців тому
My only question is How is he writing with the camera facing forward and it's not reversed !?
@IBMTechnology
@IBMTechnology 10 місяців тому
See ibm.biz/write-backwards
@Edu4Dev
@Edu4Dev Рік тому
You have to start this video answer: GraphQL ¬¬ lol
@agdevoq
@agdevoq Рік тому
Please, guys, we are still struggling to get rid of soap, we don't need another clone...
@michaelholopainen2822
@michaelholopainen2822 Рік тому
Neither, HATEOAS is the better than either of those for 95% of cases. There are some corner cases that GraphQL is better.
@ifeanyiilonze5485
@ifeanyiilonze5485 11 місяців тому
And tbh, graphql doesn't look meat at all
@_diversable_
@_diversable_ Рік тому
Please pick a lane......
@jimiscott
@jimiscott Рік тому
GraphQL mutations are god damn awful, nonsensical and a computer science abomination. GraphQL abandons the good things about REST (PUT, POST, GET) in favour of just POST. The syntax of GraphQL is awful....why was it made to be JSON non-compliant? It would have much more sense to use JSON as the base syntax for a GraphQL query/mutation. I really to struggle to see how it got any sort of foothold.
@TheDolmant
@TheDolmant Рік тому
I agree.
@imukai
@imukai Рік тому
More impressed by your backward writing capabilities but thank you for the overview.
@IBMTechnology
@IBMTechnology Рік тому
Thanks! But search on "lightboard videos" for more.
@waytospergtherebro
@waytospergtherebro Рік тому
GraphQL is for mobile developers who are too stupid to understand promises.
@dirkp.6181
@dirkp.6181 Рік тому
That's why it is only used in mobile environments, he!? :head_bang:
tRPC, gRPC, GraphQL or REST: when to use what?
10:46
Software Developer Diaries
Переглядів 64 тис.
REST vs RPC vs GraphQL API - How do I pick the right API paradigm?
15:36
Ambient Coder
Переглядів 134 тис.
didn't want to let me in #tiktok
00:20
Анастасия Тарасова
Переглядів 8 млн
格斗裁判暴力执法!#fighting #shorts
00:15
武林之巅
Переглядів 7 млн
The most important AI trends in 2024
9:35
IBM Technology
Переглядів 183 тис.
What is a REST API?
9:12
IBM Technology
Переглядів 1,4 млн
Learn GraphQL In 40 Minutes
39:43
Web Dev Simplified
Переглядів 724 тис.
The Truth About GraphQL
12:06
Theo - t3․gg
Переглядів 90 тис.
GraphQL Crash Course - GraphQL NodeJS
42:31
Piyush Garg
Переглядів 64 тис.
Microservices explained - the What, Why and How?
18:30
TechWorld with Nana
Переглядів 783 тис.
War of the APIs - REST vs GraphQL vs gRPC by Memi Lavi
40:45
Devoxx
Переглядів 3,8 тис.
API vs. SDK: What's the difference?
9:21
IBM Technology
Переглядів 1,4 млн
gRPC vs REST - KEY differences and performance TEST
7:02
Jelvix | TECH IN 5 MINUTES
Переглядів 13 тис.
GraphQL vs REST: what you need to know
10:11
Kodaps Academy
Переглядів 14 тис.
didn't want to let me in #tiktok
00:20
Анастасия Тарасова
Переглядів 8 млн