SlideShare a Scribd company logo
GraphQL vs
Traditional REST API
Vladimir Dejanović
Prague, 18-19 October 2018
@VladimirD_42
Vladimir Dejanović
Let’s Meet
@VladimirD_42
vladimir@itshark.xyz
http://itshark.xyz
@VladimirD_42
Vladimir Dejanović
Let’s Meet
http://itshark.xyz
@VladimirD_42
Vladimir Dejanović
Let’s Meet
@VladimirD_42
Vladimir Dejanović
Let’s Meet
and Others...
@VladimirD_42@geecon
Agenda
@VladimirD_42@geecon
Agenda
REST
@VladimirD_42@geecon
Agenda
REST
GraphQL
@VladimirD_42@geecon
Agenda
REST
GraphQL
GraphQL vs REST
@VladimirD_42@geecon
Agenda
REST
GraphQL
GraphQL vs REST
Questions
@VladimirD_42@geecon
What is REST?
@VladimirD_42@geecon
REST
http://www.ics.uci.edu/~fielding/pubs/
dissertation/rest_arch_style.htm
@VladimirD_42@geecon
REST
Client-Server Architecture
@VladimirD_42@geecon
REST
Statelessness
Client-Server Architecture
@VladimirD_42@geecon
REST
Statelessness
Cacheability
Client-Server Architecture
@VladimirD_42@geecon
REST
Statelessness
Cacheability
Layered System
Client-Server Architecture
@VladimirD_42@geecon
REST
Statelessness
Cacheability
Layered System
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
REST
Statelessness
Cacheability
Layered System
Uniform Interface
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
REST in real life
@VladimirD_42@geecon
REST in real life
@VladimirD_42@geecon
REST in real life
@VladimirD_42@geecon
REST in real life
@VladimirD_42@geecon
Simple Blog
@VladimirD_42@geecon
Simple Blog
Author
id
name
@VladimirD_42@geecon
Simple Blog
Author
id
name
Post
id
title
body
authorId
@VladimirD_42@geecon
Simple Blog
Author
id
name
Post
id
title
body
authorId
Comment
id
text
postId
authorId
@VladimirD_42@geecon
Simple Blog
https://github.com/vladimir-dejanovic/graphql-
vs-traditional-rest-api-conftalk_demo
Branch: rest-0.1
@VladimirD_42@geecon
What is GraphQL?
@VladimirD_42@geecon
GraphQL
GraphQL is a query language
for APIs
@VladimirD_42@geecon
GraphQL
is
specification
@VladimirD_42@geecon
GraphQL
graphql-java
@VladimirD_42@geecon
GraphQL
Talking is boring
Show Code
@VladimirD_42@geecon
Simple Blog GraphQL Code
https://github.com/vladimir-dejanovic/graphql-
vs-traditional-rest-api-conftalk_demo
Branch: graphql-0.1
@VladimirD_42@geecon
GraphQL
Statelessness
Cacheability
Layered System
Uniform Interface
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
GraphQL
Statelessness
Cacheability
Layered System
Uniform Interface
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
GraphQL
Statelessness
Cacheability
Layered System
Uniform Interface
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
GraphQL
Statelessness
Cacheability
Layered System
Uniform Interface
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
GraphQL
Statelessness
Cacheability
Layered System
Uniform Interface
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
GraphQL
Statelessness
Cacheability
Layered System
Uniform Interface
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
GraphQL
Statelessness
Cacheability
Layered System
Uniform Interface
Client-Server Architecture
Code on Demand (Optional)
@VladimirD_42@geecon
REST
Schema Optional
@VladimirD_42@geecon
REST
Schema Optional
Good practice, but still optional
@VladimirD_42@geecon
GraphQL
Schema is MANDATORY
@VladimirD_42@geecon
GraphQL
@VladimirD_42@geecon
GraphQL
@VladimirD_42@geecon
GraphQL
@VladimirD_42@geecon
GraphQL
@VladimirD_42@geecon
GraphQL
@VladimirD_42@geecon
GraphQL
@VladimirD_42@geecon
REST
@VladimirD_42@geecon
Simple Blog GraphQL Code
https://github.com/vladimir-dejanovic/graphql-
vs-traditional-rest-api-conftalk_demo
Branch: graphql-0.2
@VladimirD_42@geecon
GraphQL
Post
Comment
Author
@VladimirD_42@geecon
GraphQL
Post
Comment
Author
@VladimirD_42@geecon
GraphQL
Post
Comment
Author
@VladimirD_42@geecon
GraphQL
Post
Comment
Author
@VladimirD_42@geecon
GraphQL
Post
Comment
Author
@VladimirD_42@geecon
GraphQL
Post
Comment
Author
@VladimirD_42@geecon
Simple Blog GraphQL Code
https://github.com/vladimir-dejanovic/graphql-
vs-traditional-rest-api-conftalk_demo
Branch: graphql-0.3
@VladimirD_42@geecon
GraphQL
GraphQL is a query language
for APIs
@VladimirD_42@geecon
GraphQL
API
@VladimirD_42@geecon
GraphQL
Powerful Query Language
@VladimirD_42@geecon
GraphQL
Client call the shots
@VladimirD_42@geecon
GraphQL
Post
Comment
Author
@VladimirD_42@geecon
GraphQL
Post
Comment
Author
@VladimirD_42@geecon
Abuse of GraphQL
query {
allPosts {
title
comments {
text
createdBy {
name
posts {
title
comments {
text
@VladimirD_42@geecon
Abuse of GraphQL
query {
allPosts {
title
comments {
text
createdBy {
name
posts {
title
comments {
text
@VladimirD_42@geecon
Protect from Abuse
@VladimirD_42@geecon
Protect from Abuse
Time Out
@VladimirD_42@geecon
Protect from Abuse
Time Out
Max Query Depth
@VladimirD_42@geecon
Protect from Abuse
Time Out
Max Query Depth
Max Query Complexity
@VladimirD_42@geecon
Protect from Abuse
Time Out
Max Query Depth
Max Query Complexity
Throttling
@VladimirD_42@geecon
GraphQL query language for API
@VladimirD_42@geecon
GraphQL query language for API
Query
@VladimirD_42@geecon
GraphQL query language for API
Query
Mutation
@VladimirD_42@geecon
Simple Blog GraphQL Code
https://github.com/vladimir-dejanovic/graphql-
vs-traditional-rest-api-conftalk_demo
Branch: graphql-0.4
@VladimirD_42@geecon
GraphQL query language for API
Query
Mutation
Subscription
@VladimirD_42@geecon
GraphQL questions to ask
@VladimirD_42@geecon
GraphQL questions to ask
Error Responses
@VladimirD_42@geecon
GraphQL questions to ask
Error Responses
Performance & Cache
@VladimirD_42@geecon
GraphQL questions to ask
Error Responses
Performance & Cache
Authentication & Authorisation
@VladimirD_42@geecon
GraphQL
Vs
Traditional REST API
@VladimirD_42@geecon
GraphQL vs Traditional REST API
“Similar”
@VladimirD_42@geecon
GraphQL vs Traditional REST API
“Similar”
Tools & Knowledge
@VladimirD_42@geecon
GraphQL vs Traditional REST API
“Similar”
Tools & Knowledge
“Old Tricks”
@VladimirD_42@geecon
GraphQL vs Traditional REST API
GraphQL rich SDL
@VladimirD_42@geecon
GraphQL vs Traditional REST API
GraphQL rich SDL
GraphQL powerful Query Language
@VladimirD_42@geecon
Thank You
@VladimirD_42@geecon
References
https://github.com/vladimir-dejanovic/graphql-
vs-traditional-rest-api-conftalk_demo
http://www.ics.uci.edu/~fielding/pubs/dissertat
ion/rest_arch_style.htm
@VladimirD_42
Questions
@VladimirD_42
vladimir@itshark.xyz
http://itshark.xyz
@geecon

More Related Content

GraphQL vs Traditional Rest API [GeeCon Prague 2018]