What Is GraphQL? REST vs. GraphQL

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024
  • To get better at system design, subscribe to our weekly newsletter: bit.ly/3tfAlYD
    Checkout our bestselling System Design Interview books:
    Volume 1: amzn.to/3Ou7gkd
    Volume 2: amzn.to/3HqGozy
    ABOUT US:
    Covering topics and trends in large-scale system design, from the authors of the best-selling System Design Interview series.

Комментарии • 221

  • @eltreum1
    @eltreum1 Год назад +13

    GraphQL was designed by Facebook to solve over fetching problems aggregating data lakes containing overlapping/duplicate data sometimes from uncontrolled 3rd parties for a global service that processes millions of write and read queries per hour 24/7. It can be useful for taming bloated data lakes or getting more out of old systems. If you are building a new system ground up you probably won't need it unless your data models are very complex with giant records, but probably a just bad design.
    I have seen startups fail because they wasted time and money on GQL when they didn't really need it or the complexity it adds made getting the service to work well difficult or fragile. Don't engineer like FB and Google until you are that big and make a system that gets the objective work done well and code it so it can grow and modularize later if needed.

  • @manu144x
    @manu144x Год назад +17

    It always seemed to me that graphQL is only worth it beyond a certain level of complexity and when you're dealing with an extremely varied array of clients each needing different fields, different data, different implementations. This gives the clients maximum flexibility and you move a lot of the complexity to the client side. If you don't want to implement hundreds of endpoints and API's you just create the graphql middleware, schemas and you're good to go.
    But security is a big risk, you need to make sure sensible data is not being returned in any way, not to mention you introduce a lot more possibilities for bugs.

    • @tomu5642514
      @tomu5642514 Год назад +4

      Exactly, for me it's pretty clear that the main use case of graphql it's one where you have as you said a varied array of clients who evolve independently from your api implementation and you have a complex data model that otherwise requires multiple endpoint implementations. Only in this case the tradeoff between this extra layer of complexity and cost it's worth for a business.

  • @khalilshaik6161
    @khalilshaik6161 Год назад +2

    very clear explanation!
    instantly subscribed!

  • @nyplace1
    @nyplace1 Год назад

    amazing animations, a very clear explanation, thank you!

  • @HaroonCodes-fj8mp
    @HaroonCodes-fj8mp 4 месяца назад

    Very Well explained.

  • @marvhan888
    @marvhan888 Год назад +2

    5 star video

  • @nickolaskraus
    @nickolaskraus Год назад

    I liked the nod to the SpaceX Dragon capsule in the GraphQL schema 😏

  • @alexandervashchuk7795
    @alexandervashchuk7795 7 месяцев назад

    great breakdown, thanks

  • @NursultanBegaliev
    @NursultanBegaliev 10 месяцев назад

    Thank you! Great video.

  • @sumitagrawal2009
    @sumitagrawal2009 Год назад +1

    So where to use Graphql?

  • @حساممجيبالبرطي
    @حساممجيبالبرطي Год назад

    Where are they better to use in terms of safety and cost?

  • @JamesSmith-i9q
    @JamesSmith-i9q 23 дня назад

    Miller Cynthia Taylor Mary Davis Daniel

  • @codegreenie3429
    @codegreenie3429 Год назад

    I have realised that top companies like Meta & Google only create solutions for their heavy workload. Small teams with a 25k user base should not bother trying to implement what companies like Facebook created. It is highly unnecessary. I have a 2k daily user base app. I don't need GraphQL

  • @oscareriksson9414
    @oscareriksson9414 Год назад

    Nice video!
    Hmm so like it's a tool to make queries, so it's for smaller companies who can't afford many programmers. Or maybe even none. That's cool I guess. But why would any company want that, who can actually afford developers? It makes it more difficult to customise products or services. You want to do something that GQL (or other) has not implemented? Forget it, follow the boxes of the master, and pay us for it too mmmuuuuuhahahahahahahahahaaaaaaa!! 😉

  • @BJHzlz
    @BJHzlz Год назад

    Why not simply run SQLike query at frontend 🤣 GraphQL ~= SQL ?

  • @HuntingtonFrank-s7q
    @HuntingtonFrank-s7q 14 дней назад

    Walker Kenneth Jones James Martin Michelle

  • @FredMyrna-x2f
    @FredMyrna-x2f 5 дней назад

    Hall Michelle Smith Sarah Martin James

  • @是我-n8q
    @是我-n8q Год назад

    enligsh is 困难 to understand

  • @dmitrylubyanov7277
    @dmitrylubyanov7277 Год назад +194

    Probably the most easy to understand video I've seen about differences between REST and GraphQL. Thank you!

  • @ramkanagu
    @ramkanagu Год назад +26

    Nicely explained! In ten years down the line, GraphQL will be identified as an anti-pattern in the industry. Though it may seem very easy and attractive initially, it would become more complex once the schemas become big. REST is simple and easy to implement. The only caveat with REST is multiple api calls to backend. The better and a traditional approach should be by introducing orchestration services for any frontend that requires more complex data models from the back end.

    • @GameboyZoneRocks
      @GameboyZoneRocks 8 месяцев назад +1

      Can you give an example of orchestration services for frontend which will circumvent GraphQL? Your comment was interesting for me.

  • @mahsatech
    @mahsatech Год назад +1

    probably better if you turned off your camera. i got a little distracted😅😅

  • @youngKOkid1
    @youngKOkid1 Год назад +83

    GraphQL seems like an ambitious & interesting idea, as well as a horrendous footgun. Thanks for the wonderful explanation as always!

  • @yp5387
    @yp5387 Год назад +153

    In my company we use GraphQL as primary API and it is not good. We are planning to move everything to REST api. Knowledge gap is the biggest trade off for us. New talent is having hard time wrapping their head around GraphQL queries. REST is pretty simple and easy to understand thus less development time for all the developers.

    • @alexkey9372
      @alexkey9372 Год назад +22

      same here. biggest mistake we've ever done. REST API is way more mature. when graphql reaches that point then we might re-consider.

    • @TheVasx
      @TheVasx Год назад +21

      Might be a bit of devs fault. New hire or not, graphql for FE is something you learn in a couple of days if you have some experience

    • @alexkey9372
      @alexkey9372 Год назад +15

      @@TheVasx in our case, it wasn't the knowledge gap but the performance. all graphql requests are POST, therefore is really hard to cache them. We thought for bigger project would be better, but that was proven to be a naive thought.

    • @TheVasx
      @TheVasx Год назад +11

      @@alexkey9372 oh yea, if you depend on caching its all a big clusterfuck 🔥🔥

    • @yp5387
      @yp5387 Год назад

      @@TheVasx Agree. And sooner or later, caching will come into the picture for sure.

  • @GameboyZoneRocks
    @GameboyZoneRocks 8 месяцев назад +1

    There are two arguments I have against GraphQL -
    1. Why can't you write efficient REST APIs so they offer precise data in one call?
    2. Assuming GraphQL Apollo React client talks to Apollo backend server, I assume the Apollo backend server is doing more querying before returning precise data to the client. There is performance overhead on the server-side, GraphQL is just offering ease, not performance optimization.
    If my above two arguments are true, GraphQL will be replaced someday by an easy-to-use REST API abstraction on the server-side, this abstraction will offer the GraphQL benefits in REST.

  • @Amulyaslays
    @Amulyaslays Год назад +19

    The graphics and animations are simply next level.

  • @golden_smiles
    @golden_smiles Год назад +14

    It is most quick , constructive and comprehensive essence of knowledge without any extra BS payload like memes and distracting videos. Thank you, sir.

  • @shutanovac
    @shutanovac Год назад +5

    Frankly I didn't understand the part with the table scan that could bring the DB down. Someone care to elaborate please?

    • @YBuda101
      @YBuda101 Год назад

      I'm not sure what the details are of his example, but as presented, that risk is possible with REST calls too. Unsure why he singled it out as a GraphQL problem

    • @DF-ss5ep
      @DF-ss5ep Год назад +1

      For example "find a user whose name matches a regex", and the name column in the DB has no index. In practice, I don't think such a query is likely to bring down the entire service, although it's possible. It would depend on how many of these queries are executed. In a bad scenario, all other queries become slow because the DB is overloaded, which causes more and more requests to accumulate, until everything fails. I don't know how GraphQL works, but with simple REST + SQL, you would use the circuit breaker pattern and use a "bouncer" (a proxy) in front of the db

    • @shhamma
      @shhamma 22 дня назад

      @@DF-ss5epYou put your sql inside a resolver like you will do it in rest api. It’s not a graphql problem or rest …

  • @patrickemuller
    @patrickemuller Год назад +27

    Great video!
    But sincerely I would continue to use JSONAPI instead of GraphQL.
    JSONAPI is super nice, supported by a lot of frameworks and it's build around the specific fields to be fetched just when they are needed... not to mention the pre-build filters that you can specific on your resources and simplify the way you filter for particular records and collections

    • @sadashivshinde9150
      @sadashivshinde9150 Год назад +5

      Thats the biased devloper inside u

    • @patrickemuller
      @patrickemuller Год назад +1

      @@sadashivshinde9150 Maybe 😂

    • @orion.5611
      @orion.5611 Год назад

      which good resources are available for learning JSONAPI. i have found a small number and i dont understand it fully

  • @swdRanaP
    @swdRanaP Год назад +3

    which software you use to crate this kind of animation video? please tell me. and thank you so much for shareing this wonderful explanation.

  • @adimardev1550
    @adimardev1550 Год назад +1

    i used to like graphql, i just realize it really sucks for handling advance api! specially when integrating with frameworks and libraries. the only thing about it is that it's database agnostic. other than that graphql really sucks. rest good but too much stuff to work. trpc is coming, and i think it's better than these two. but to see is to experience. just like graphql it sucks at the end.

  • @juliahuanlingtong6757
    @juliahuanlingtong6757 Год назад +5

    Great piece!
    Would love to have a piece elaborate on the caching behaviors of HTTP GET leveraged by browser, CDN and servers mentioned in the video.

  • @edwardokech4347
    @edwardokech4347 Год назад +22

    Awesome video...receiving all resources from one request seems great for GraphQL. However, not sure about its security capabilities and the fact caching is a headache. As a lead Engineer, I'll recommend GraphQL for our internal tools still not convinced about using it in our production apps.

    • @M3t4lstorm
      @M3t4lstorm Год назад +7

      How would GQL differ from a security perspecific than any other HTTP based API...

    • @semosancus5506
      @semosancus5506 Год назад +6

      @@M3t4lstorm Makes you wonder about the Lead Engineer....

    • @vitorguidorizzzi7538
      @vitorguidorizzzi7538 Год назад +4

      @@M3t4lstorm Not really a security issue per se, but graphql makes it easier to write very expensive queries, rest can rely on basic rate limiting but graphql also needs to block clients spaming tremendously expensive requests

  • @ngocatnguyen5771
    @ngocatnguyen5771 Год назад +5

    Tried graphql recently, after a few api, yea it's great, work smoothly, easy to implement. Then going bigger, n+1 problem, shit define, hard to track. GraphQL is shit imo

  • @tiagosutter8821
    @tiagosutter8821 Год назад +3

    thanks for content! suggestion: Odata, or maybe a video about "Rest vs. Odata vs. GraphQL"

  • @DF-ss5ep
    @DF-ss5ep Год назад +41

    To be fair, you can also accidentally do a full scan of a table in SQL too. Maybe it's just a bit less likely because developers who build the queries are more aware of what's in it than frontend developers

    • @yannistheodorakopoulos5916
      @yannistheodorakopoulos5916 Год назад +14

      Totally agree on that. But the main misconception with GraphQL is the following:
      Maybe this is the biggest mistake in GraphQL implementations. While it is meant to be a form of contract between the client and the server, in which the backend side plays the role of the aggregator that fetches data from different sources, people use it to communicate with the database layer instead.

    • @kimovitch7
      @kimovitch7 9 месяцев назад

      @@yannistheodorakopoulos5916 I thought it was obvious that graphql should be used as a backend for frontend more than for data access layer, guess people relying on it to do stuff it's not that good for...
      Graphql should just stay away from your domain/business layer

  • @ColinRichardson
    @ColinRichardson Год назад +16

    GraphQL seems like it would be AMAZING for our application, but then once you deep dive in, you realise it's actually the worst..
    Our data structure is mutable from 1 call to another since it's the user who defines what their data looks like.. (We basically have a database in a database)

    • @MrKar18
      @MrKar18 Год назад +2

      I have combination with Rest API. Most complex get calls in graphql and mutation from Rests only which gives granular control.

    • @phlr
      @phlr Год назад +1

      Sounds like you are doing something wrong. You should only expose things you want to mutate to the schema. Search for GQL best practices around mutations.

    • @ColinRichardson
      @ColinRichardson Год назад

      Everything in our data is mutatable. It's user defined, and linkable.

  • @RaymondPeckIII
    @RaymondPeckIII Год назад +7

    Interesting. I implemented some similar features in the H2O-3 REST API framework back in 2015. You can white- or black-list fields, and specify which if any child objects to return in the payload, so you didn't have to make many REST requests and assemble an object graph yourself inside the client. The query language was just REST with a couple optional parameters on top of it. It doesn't require a schema (it's schema-on read, with automatically-generated rich metadata for the schemas), or a special query language. You just specify the field paths for any child or grandchild classes you want returned.
    The API is defined in a very lightweight way, simply by creating a parameterized class for each class in the API. No boilerplate, no IDL.

  • @molomekeys3938
    @molomekeys3938 Год назад +5

    the work on animation is incredible very inspiring

  • @MatthewLeach
    @MatthewLeach Месяц назад

    It's neat, it makes sense mostly, but don't you get tired of learning all these better and more innovative tools to communicate / integrate contemporary applications?!! Or is it just me? 😞

  • @jkuang
    @jkuang Год назад +1

    I can predict with absolute certainty that this GraphQL will be yet one of the many technology junks littering the software landscape.

  • @khwarzme
    @khwarzme Год назад +2

    Thank you for the great video. What tool / software are you using for the video animation?

  • @samoniumuziejus
    @samoniumuziejus 4 месяца назад

    I would presonally just pass in an additional parameter to grab smaller or fuller version of the request, where some data could be nullable.. but if you really need that kind of flexibility then fine 😅 but is slower so...

  • @ReflectionOcean
    @ReflectionOcean Год назад +1

    Rest: simple to implement and use, with inefficiency in specific occasions because of multiple API calls required
    GraphQL: flexible and efficient to use, but complex to implement and use and often relies on extra tools

  • @complexity5545
    @complexity5545 9 месяцев назад

    This reminds me of xsd xml soap from back in the day, but graphql is better designed and controlled by smart people.

  • @StephanieDameron-h2j
    @StephanieDameron-h2j 9 дней назад

    Lewis Joseph Gonzalez Amy Martinez Scott

  • @Vedarta
    @Vedarta Год назад +2

    Great video, but I don’t see the advantage of GraphQL over JSONAPI. Also, there are several open source implementationsfor JSONAPI.
    I would only maybe use GraphQL to describe relations not predicted by a JSONAPI REST API, if that much.

  • @9unapologeticsanatani
    @9unapologeticsanatani Год назад +2

    It is indeed a good way of getting data, a proper design will help the same. I love GraphQL. Imagine I ask for a name query from an api and it gives me 200 fields that I don't even want ! See ?

    • @clumsyjester459
      @clumsyjester459 Год назад

      That's solvable with REST as well. You just get a small subset of columns by default and pass a query param to get additional ones. Sure, GraphQL is still more flexible, but I don't see how the tradeoffs are worth it.

  • @thiabara7242
    @thiabara7242 13 дней назад

    anyone knows the software used for graphic and animation slides?

  • @ahmedeox
    @ahmedeox 9 месяцев назад

    how is this in principle different from soap and exchangign wsdl schemas?

  • @charuwaka1
    @charuwaka1 Год назад +2

    The way you explained is TOP NOTCH

  • @JaneJuliet-m9x
    @JaneJuliet-m9x 16 дней назад

    Martin Linda Thomas Angela Robinson Betty

  • @mokyyds
    @mokyyds Год назад +1

    Like, your video content is very professional, what software did you use to make the video? thanks

  • @HANNAHSdigitaldiaries
    @HANNAHSdigitaldiaries Год назад +1

    Is it same persistent tables for GraphQL and REST? If so, can GraphQL guarantee atomic operations across tables?

    • @vitorguidorizzzi7538
      @vitorguidorizzzi7538 Год назад

      graphql is just a specification for http requests, it does not interfere with your tables.

  • @code-tips
    @code-tips Год назад +1

    Nice video 👏👏. Which tool are you using for making such great videos?

  • @BunmJyo
    @BunmJyo 8 месяцев назад

    ByteByteGo 中文名称是啥呐? 字节奔跑? 字节行动?

  • @goldfishbrainjohn2462
    @goldfishbrainjohn2462 Год назад +2

    I like this channel.
    Valuable technical system design series.

  • @zoomzoom1889
    @zoomzoom1889 Год назад +1

    thank you for this! extremally valuable resources, please keeping making this content

  • @CalvinStevens-g2p
    @CalvinStevens-g2p 15 дней назад

    Lopez Carol Rodriguez Angela Harris Laura

  • @idanadowman2012
    @idanadowman2012 18 дней назад

    Perez Steven Wilson Margaret Wilson Linda

  • @neildutoit5177
    @neildutoit5177 Год назад +1

    What is the GraphQL analogue for HATEOAS? I.e. how do you discover resources?

  • @satish1012
    @satish1012 7 месяцев назад

    any one understood at 4:21 . What he meant? How does the entire table span occurs?

  • @StevenSanders-y3q
    @StevenSanders-y3q 8 дней назад

    Lopez Jose Wilson Dorothy Thomas Larry

  • @Jayme-r5m
    @Jayme-r5m 17 дней назад

    Martin Dorothy Davis Shirley Lewis Gary

  • @matthiasdebernardini3388
    @matthiasdebernardini3388 Год назад +2

    such a great video - love the channel!

  • @MrPilz28
    @MrPilz28 Год назад +4

    Great work as always ! I'm really impressed by the quality of your slides

  • @iury664
    @iury664 4 месяца назад

    u put ; after $petType, but : after $name. is it correct?

  • @asdrubalsoto-o1f
    @asdrubalsoto-o1f 14 дней назад

    Perez Carol Lewis Michael Lewis Donna

  • @FinderFlush-e1p
    @FinderFlush-e1p 17 дней назад

    White Gary Wilson Kenneth Thomas Kevin

  • @leomysky
    @leomysky Месяц назад

    Amazing video, thanks for it

  • @SamRice-j2l
    @SamRice-j2l Месяц назад

    Lee Daniel Jones Eric Anderson Thomas

  • @mitotv6376
    @mitotv6376 Год назад +1

    Nice explanation

  • @jacquesmatike9289
    @jacquesmatike9289 Год назад +2

    Good explanations ... good animations !!

  • @VaniGwynn
    @VaniGwynn 25 дней назад

    Lee Margaret Miller Daniel Taylor Kimberly

  • @a-yon_n
    @a-yon_n Год назад

    Should I use GraphQL? If you ask yourself such a question, that already suggests NO. GraphQL is very dangerous if not implemented carefully.

  • @vskovzgird
    @vskovzgird Год назад +1

    Dude, you are the best. Thanks! Keep it up!

  • @JessicaLopez-o5j
    @JessicaLopez-o5j Месяц назад

    Hall Gary Moore Amy Davis Sarah

  • @FlynnVito-t4f
    @FlynnVito-t4f 9 дней назад

    Moore Gary Taylor George Allen Larry

  • @mineralisk
    @mineralisk Год назад +1

    Thanks for the quality content.

  • @dushyantchaudhry4654
    @dushyantchaudhry4654 7 месяцев назад +1

    2:11 to 2:21 a superb concise explanation of the difference.

  • @roman3249
    @roman3249 Год назад

    In previous video I just watched they told that n+1 problem is a problem of GraphQL approach, in this video they told that n+1 problem is a problem of REST approach 🤯

  • @javawicode
    @javawicode Год назад

    But still we can prepare query in REST that we specify parameters and others things.

  • @davidagyakwa288
    @davidagyakwa288 Год назад +1

    What about rest and GRpc

  • @allezvenga7617
    @allezvenga7617 Год назад +1

    Thanks for your sharing

  • @rahatsshowcase8614
    @rahatsshowcase8614 Год назад

    this was best ! because everyone was speaking regarding graphql directly and i was thinking its a sql languange XD

  • @gauravmisal4610
    @gauravmisal4610 9 месяцев назад

    hey what if the query is too long ?

  • @jordyvu999
    @jordyvu999 Год назад

    Thank you for great video, tRPC is now gaining growth and replace graphql

  • @AjitYadav-sy3dh
    @AjitYadav-sy3dh Месяц назад

    Binod. Good.

  • @user-qy7mb5ho9e
    @user-qy7mb5ho9e Год назад +1

    Fantastic Motion animation btw

  • @MythicEcho
    @MythicEcho Год назад

    I immediately went to your channel to watch more videos, but the count is very low. But thats the catch, quantity > quality.

  • @gdw888
    @gdw888 Год назад

    This looks really nice but it adds extra complexities users might not want to adopt.

  • @tomtomtomtom691
    @tomtomtomtom691 Год назад

    I don’t get why the problem described at the end is specific to GraphQL.

  • @andresa9913
    @andresa9913 Год назад

    Seems like graphql is not so good and we should keep using rest, did I understood correctly?

  • @JorgeAndresMorenoJAimes
    @JorgeAndresMorenoJAimes Год назад +6

    Cool. Thanks. I know this might by obvious for some people. But what about "security". Is possible to implement that with Graphql?. I know with rest API I can limit the information an user can have and who can access that. I don't have experience with Graphql

    • @nosyarlin
      @nosyarlin Год назад +1

      You should be able to. I was using graphql-ruby in my previous job and you can use pundit with it to control which users are allowed to see which objects and which fields. I'm sure other graphql libraries will have similar features

    • @M3t4lstorm
      @M3t4lstorm Год назад +3

      This kind of 'security' doesn't even belong in the API layer, so yes GQL can

    • @daviduzumaki
      @daviduzumaki Год назад

      you can make requests require tokens for authentication in the auth header of a graphql request

    • @MrKar18
      @MrKar18 Год назад

      Ofcourse. Oauth or other can be enabled as you know the endpoint being exposed. Frameworks allow that seamless.

  • @MarcoLenzo
    @MarcoLenzo Год назад

    Which program do you use for animations?

  • @user-qy7mb5ho9e
    @user-qy7mb5ho9e Год назад +1

    Thx! So helpful!!

  • @jamesT008
    @jamesT008 Год назад +3

    To the point and precise explanation. Nothing bla bla !!
    Very nice!

    • @drift_ah1518
      @drift_ah1518 Год назад

      exactly what i thought - nice to spend exactly the minutes required to appraise oneself of a technology. plus i especially liked his no nonsense take on the pros and cons. a really good job/video

  • @whonayem01
    @whonayem01 Год назад +1

    Thanks

  • @casual_sky2
    @casual_sky2 Год назад +1

    This is a fantastic video! Thanks for the comparisons, it really helped me understand what was going on. I was having trouble understanding the concepts seeing as not many people explain it this simply and I didn't have time to dig into the documentation... Thanks a lot. I'll be sharing this video for anybody else who needs a quick, no fuss intro to graphql.

  • @deepanshukacher1536
    @deepanshukacher1536 Год назад

    Really clarify my understanding of their usage

  • @eminberkay
    @eminberkay Год назад

    Excellent explanation, thanks! subscribed 👍