If you know what I mean
GRAPHQL IS ACTUALLY REST
JAKUB RIEDL
Software Engineer @iflix
lead of GraphQL project
In we redefine television for a billion people
WHY DO WE NEED API?
WHY DO WE NEED API?
TO TRANSFER STATE BETWEEN BACKEND AND FRONTEND
1999
SOAP
HISTORY OF WEB API TECHNOLOGIES
2000
REST
2007
OData
2015
GraphQL
Falcor
2013
JSON API
● A protocol
● XML Based
● RPC methods
● Usually over HTTP or SMTP
SOAP Standard Object Access Protocol (1999)
SOAP Standard Object Access Protocol (1999)
● Architectural style introduced by Roy Fielding in his PhD dissertation
● Most commonly uses JSON
● Centered around resources
● Usually over HTTP
REST Representational State Transfer (2000)
● Client - Server
● Stateless
● Cacheable
● Layered System
● Uniform Interface
○ Identification of resources
○ Manipulation of resources through these representations
○ Self-descriptive messages
○ Hypermedia as the engine of application state
REST ARCHITECTURAL CONSTRAINTS
REST Representational State Transfer (2000)
RESTful One endpoint per resource
Users CommentsPosts
Browser AndroidiOS
- Server centric
Pros
- Flexible
- Easy to implement
- Decoupled features
Cons
- Coupled BE w/ FE
- Lots of roundtrips
- Over-fetching
- Inconsistent
- Complex clients
- Client centric (ish)
Pros
- One round trip
- Exactly what you need
Cons
- Inflexible
- Inconsistent
- Expensive
- Slow to iterate
REST-ish One endpoint per view (Backend for frontend)
View A (web)
View C
(mobile)
View B (web)
Browser AndroidiOS
RESTful One gateway with resources
Users CommentsPosts
Browser AndroidiOS
Standardized API Layer
Pros
- Flexible
- Decoupled
- No extra roundtrips
- Consistent
- Easier for clients
Cons
- Single point of failure
- Perf overhead
STANDARDIZATION
1960 2016
Users CommentsPosts
Browser AndroidiOS
Requirements
- Client centric
- Minimize roundtrips
- Reduce data transfer
- Flexible
- Decoupled
- Consistent
?
Users CommentsPosts
Browser AndroidiOS
Real Requirements
- Fast to iterate
- Time to market
- Developer experience
- Tooling
- Docs
?
● $select: choose which fields you want
● $expand: fetch related resources
● $top + $skip: pagination
● $filter (eq, lt, startswith, ...): server-side filtering
● $metadata: introspection + discovery
ODATA “The best way how to REST” *
* says Microsoft
ODATATM
ODATATM
ODATATM
£9.59
per month
● All data modelled as a JSON object with references
● All values resolve asynchronously
● “Routes” determine how data is fetched
● Data is treated as graph
● Easy to learn & use
● No type system, no arguments
● Limited tooling
FALCOR
FALCOR
● “The clean way”
● Leverages features of HTTP (caching, content negotiation, ...)
● Not typed by default
● Limited tooling
JSON API
JSON API
● Easy-to-use query language
● Strongly typed = consistent
● Very popular last months
● Great tooling
● Ready made clients
● Great developer experience
● Complexity comes with scale
GRAPHQL
GRAPHQL
developer.iflix.com
real world example
● Client - Server
● Stateless
● Cacheable
● Layered System
● Uniform Interface
○ Identification of resources
○ Manipulation of resources through these representations
○ Self-descriptive messages
○ Hypermedia as the engine of application state
IS GRAPHQL RESTful?
● Every object/resource has a globally unique id
● Every resource can be retrieved given its id
NODE INTERFACE
NODE INTERFACE
Uniform interface
● Identification of resources
● Manipulation of resources through these representations
● Self-descriptive messages
● Hypermedia as the engine of application state
GRAPHQL + NODE INTERFACE == RESTful
WHAT TO CHOOSE?
WHAT TO CHOOSE?
IT DEPENDS.
SUMMARY
SUMMARY
REST IS NOT A STANDARD
SUMMARY
REST IS NOT A STANDARD
FOCUS ON YOUR NEEDS
THANKS TO
JONAS HELFER: GRAPHQL - EVOLUTION OR REVOLUTION?
3
8
WE ARE HIRING
.com
jakubriedl.com
@jakubriedl
jakubriedl
jakubriedl
GET IN TOUCH

GraphQL is actually rest