GraphQL
Better alternative for Restful apis
jaro@nous.lt | @chompomonim | +JaroSatkevic
![](https://s3.amazonaws.com/media-p.slid.es/uploads/452026/images/3354515/pasted-from-clipboard.png)
Full stack
Full stack
Back-end
Business logic
Database
Algorithms
Full stack
Back-end
Business logic
Database
Algorithms
Font-end
DOM
JavaScript
Styling/CSS
Design
Full stack
Back-end
Business logic
Database
Algorithms
Font-end
DOM
JavaScript
Styling/CSS
Design
Operations
Deployment
Server administration
Backups
Full stack
Back-end
Business logic
Database
Algorithms
Font-end
DOM
JavaScript
Styling/CSS
Design
User testing
Operations
Management
Product ownership
Deployment
Server administration
Backups
Marketing
![](https://s3.amazonaws.com/media-p.slid.es/uploads/452026/images/3354515/pasted-from-clipboard.png)
- About GraphQL with full stack in mind
- Basics and short history of GraphQL
- My experience with Apollo stack
- GraphQL server - where to start, what to avoid
AGENDA
REST is cool, but...
How many queries do we need to render this view?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/452026/images/3356566/Screen_Shot_2016-12-21_at_17.30.53.png)
Over-fetching
Hard to design "proper" api
Documentation hell
Data fetching is a problem
![](https://s3.amazonaws.com/media-p.slid.es/uploads/452026/images/3356798/Screen_Shot_2016-12-21_at_13.56.05.png)
What is GraphQL?
A query language for your API
Short facts:
- Invented at Facebook 4 years ago
- OpenSourced in summer 2015
- Already used at Github, Pinterest, Coursera, Shopify, Intuit, WIX and many more ...
{
presentation(id: "20161221-2") {
title
date
presenter {
name
email
}
}
}
{"data": {
presentations: {
title: "GraphQL - better approach for API",
date: 1482337923,
presenter: {
name: "Jaro Šatkevič",
email: "jaro@nous.lt"
}
}
}
type Presentation {
id: String!
title: String
date: Int
presenter: Presenter
}
type Presenter {
name
email
presentations: [Presentation]
}
![](https://s3.amazonaws.com/media-p.slid.es/uploads/452026/images/3354515/pasted-from-clipboard.png)
GraphQL clients
![](https://s3.amazonaws.com/media-p.slid.es/uploads/452026/images/3356775/images.png)
Relay
Features I wanted as UI developer
- Fast data queries with all&only needed data
- Data caching, to avoid refetching
- Allow to work offline
- Specify queries, parses data
- Easy to paginate
- Execute mutations, with cache and pagination
GraphQL server isn't that easy...
Tips & tricks
- Use limits on bigger amount of data
- Define schema first
- Read carefully full specification, it may help
Questions
jaro@nous.lt | @chompomonim | +JaroSatkevic
GraphQL
By Jaro
GraphQL
- 1,047