GraphQL vs REST APIs | What's the Best Kind of API?

preview_player
Показать описание
In this video, I explain what GraphQL and REST APIs are, how it works and which is the best way of API for your projects.

In REST architecture, APIs expose their functionality as resources, which are any type of service, data, or object that a client can access. Every resource comes with its own unique URI (Uniform Resource Identifier) that a client can access by sending a request to the server.

So, whenever a client calls a RESTful API, the server will respond with a representation of the state of the queried resource. Many common REST implementations utilise the standard HTTP methods (GET, POST, PUT, DELETE, and PATCH) to call a server.

In GraphQL, a set of information is seen in the context of a graph, just as the name suggests. Nodes, which are defined using the GraphQL schema system, represent objects. And edges represent the connection between nodes in the graph. This enables clear relationships between queries and increases the connectivity between objects.

GraphQL allows users to request data from several resources using a single request. Rather than making multiple requests to fetch data, you can use it to make ad-hoc queries to a single endpoint and access all the required data.

Timestamps:
0:00 Video Starts
0:37 REST API
2:20 REST is a convention
3:09 REST Status Codes
5:19 GraphQL
7:17 GraphQL Query
10:26 GraphQL is Schema Based
11:38 GraphQL Mutations
13:05 Conclusion
14:43 Outro

👉 Checkout codedamn on social:

If you found the video valuable, please leave a like and subscribe ❤️ It helps the channel grow and helps me pumping out more such content.

👋 About Me:
Hey! I'm Mehul Mohan, a CSE'21 graduate from BITS Pilani, Goa. I started coding early in life, at the age of 13 when I created my first blog on Blogger. I am listed in Google, Microsoft, Sony, eSet, etc. Hall of Fame for reporting vulnerabilities in their systems.

🍎 I am Apple's WWDC'19 Scholar - visited San Francisco and attended WWDC.

🚀 Currently working on my own startup - codedamn.

Connect with me:

🏷 Video Tags:
GraphQL vs REST APIs | What's the Best Kind of API?
graphql vs rest
GraphQL vs. REST: A Comprehensive Comparison
graphql vs rest api
rest api tutorial
rest api explained
rest vs graphql 2021
rest vs graphql api
what is graphql and why use it
what is rest api
rest api tutorial for beginners

Рекомендации по теме
Комментарии
Автор

IMO there is no best kind of API ... they both solve problems in their own ways. What you choose depends on what you are trying to achieve in what circumstance. The video covers everything up nicely. Good job dude!!

TheSiddharth
Автор

bro I just love these explainer videos. You have got a unique niche of explaining everyday developer stuff with a whiteboard and in a simple manner. Keep them coming.

pranab
Автор

This guy is the best! I came for WebSockets vs HTTP, and just went down a rabbithole.

michaelhashimoto
Автор

The best explanation I've ever seen on GraphQL and REST API. Keep these videos coming.

divyanshusoni
Автор

Love these random topics you keep making videos on. I keep learning different things. Thanks to youtube's algo too.

cristianouzumaki
Автор

I love both GraphQL and REST API's on the back-end. The tricky part to me is on the front-end. Apollo Client with React is complex setting up the Cache. I heard that it's easier with React-Query. Whereas I can do simple API calls: POST, GET, UPDATE, and DELETE.

craigjohnson
Автор

Even if know topics, I always learn new things from your videos. Thankyou keep posting.

bhaskardixit
Автор

6:51 The reason I love GraphQL. Thanks, Mehul bhaiya for the explanation.

gourangabhattacherjee
Автор

If you use nestjs then it can autogenerate the schema for you based on code by providing some decorators for your code. Alternatively if you have a schema already you can generate types for your backend from schema file. Additionally you can generate boilerplate for grapgql object with the nest cli. Im new to graphql but enjoying it with nestjs. I think nestjs, typeorm and graphql is really powerful combo ❤️

YOUdudex
Автор

I am really liking the kind of topics you are choosing.

gnanasekaran
Автор

The explanation is great but kindly manage that ring light.

thakursatyam
Автор

No bullshit, this guy is the best. If you want coding explained well, get an indian. Also applies to pretty much any subject.

defaultdefault
Автор

This one is really amazing now I will definitely try graphQL. Thanks for the wonderful explanation bro 😎🔥🔥🎉🎉

Sandeep-zddq
Автор

Graphql for connected data, REST for the rest.

akashsxo
Автор

In REST also, we can have select params in query parameter as a comma-separated string, right?

ebinantoneyt
Автор

One of the best explanations on YouTube!

I still wonder one thing though... The GQL server returns a single response with exactly the data you need which makes it fast. However, wouldn't the GQL server still fetch the same amount of data from the DB? For example if you need a couple of fields from large userData collection that's tied to another large user collection, wouldn't GQL query the entirety of both of those collections from the DB? I get that not sending those over HTTP is a benefit but is it that much faster or am I missing something? On top of that, you have the data resolution that you have to do in the GQL server before sending it to the client which adds another layer of processing.

Todiros
Автор

This was a great video on each individual approach, but unfortunately did not live up to the title in actually comparing the two approaches in terms of use-case apart from detailing that a GraphQL req has the ability to control the fields returned. Still though, I really enjoy these videos! Keep it up!

ShaggyKris
Автор

Hey Bro
Good and Informative Content
Just Remove Background Music

shivagupta
Автор

GraphQL is way to go for me though 🔥🔥
Videos are lit BtW

shashanksingh
Автор

Thanks for such awesome videos, always waiting for your new videos, will be glad to get t-shirt giveaway

Sonu-tgtg