0% found this document useful (0 votes)
19 views

GraphQL SummaryIntro

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

GraphQL SummaryIntro

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

rootlearn.

com

GraphQL
A visual introduction

root
Manish Poduval
1/10 rootlearn.com

root
What is it ?
A Query Language

In simple terms, it is a way of fetching only the data


that you need from the server.

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

API to fetch posts


ipsumlorem ipsum lorem ipsum lorem
ipsumlorem ipsum

March 21st Explaining with


pokemon is fun

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

How only a single endpoint ?


It does that using a GraphQL
strongly typed schema
Schema

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 {

A simple “Worm” schema id: ID

using Types and Fields name: String

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

Suitable for smaller


Tailored requests networks
GraphQL
Strongly typed API growth without
versioning

Manish Poduval
Want to be a part of root ?

Scan to upskill
yourself

You might also like