GraphQL SummaryIntro
GraphQL SummaryIntro
com
GraphQL
A visual introduction
root
Manish Poduval
1/10 rootlearn.com
root
What is it ?
A Query Language
Manish Poduval
2/10 rootlearn.com
root
Techincally it’s an API standard/specification and can
be implemented irrespective of the tech stack
Check the specs at
specs.graphql.org
Visualizing it, you could see it as this way.
GraphQL
Client Server
Manish Poduval
3/10 rootlearn.com
root
How is it better than REST API’s
Well, let’s say you’re building a blogging website
Assume you’re using 3 APIs to get data
An API to fetch user
Manish’s posts details with extra info
lorem ipsum lorem some random post
Followers:
API to fetch followers
details
Manish Poduval
4/10 rootlearn.com
root
with GraphQL you’d only need 1
HTTP POST
GraphQL
Client Server
Manish Poduval
5/10 rootlearn.com
root
The Schema Definition Language (SDL)
The SDL consists of a few basic parts. With the SDL we
can create our schema.
A schema defines the shape of our data
SDL
Types Mutation
Fields Scalars Query
type Worm {
Manish Poduval
6/10 rootlearn.com
root
Thinking in graphs . . .
You can also establish relations between types
type Worm {
type Home {
id: ID
id: ID
name: String
title: String
loc: [Home]
}
Manish Poduval
7/10 rootlearn.com
root
There are two operations you can do
Queries Mutations
They are used to They are used to create.
retrieve data update or delete data
{
worms {
mutation {
names
createWorm(legs: “7”)
}
}
}
Fetches the names from a Would create a worm
worms list API entry
There is also “Subscriptions”.
(Topic for another day )
Manish Poduval
8/10 rootlearn.com
root
You get the picture right ?
Our query
worm(color: “green”) {
body
GraphQL
Manish Poduval
9/10 rootlearn.com
root
GraphQL has it’s benefits
Can be used in any No over-fetching or
tech stack under-fecthing data
Manish Poduval
Want to be a part of root ?
Scan to upskill
yourself