Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GraphQL
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Radoslav Stankov
August 15, 2015
Technology
1.2k
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphQL
Video:
https://www.youtube.com/watch?v=T2cucknCd6M
Radoslav Stankov
August 15, 2015
More Decks by Radoslav Stankov
See All by Radoslav Stankov
Building LLM Powered Features
rstankov
0
160
Tips for Tailwind CSS
rstankov
0
68
Building LLM Powered Features (lightning talk)
rstankov
0
80
All you need is CSS
rstankov
0
150
Ruby on Rails The Single Engineer Framework
rstankov
0
61
Rails: The Missing Parts
rstankov
1
270
The dream that turned into nightmare
rstankov
0
330
The dream that turned into nightmare (lightning)
rstankov
0
140
Ruby on Rails - The Single Engineer Framework
rstankov
0
370
Other Decks in Technology
See All in Technology
AIに「使われる」時代のSaaS戦略 〜既存WebAPIのMCPサーバー化における開発ノウハウ〜
ekispert_api
0
300
“ID沼入口” - 基本とセキュリティから始める、考え続けるためのID管理技術勉強会 告知&イントロ
ritou
0
430
product engineering with qa
nealle
0
150
アラート調査向けAIエージェントの本番導入とその後/AI Agents for Alert Investigation: Production Deployment and After
taddy_919
1
390
Control Planeで育てるBtoB SaaSの認証基盤 - SRE NEXT 2026
pokohide
1
830
はじめてのWDM
miyukichi_ospf
1
120
環境凍結という Toil を倒す -セルフサービス型 Ephemeral テスト環境の 設計と実践
shirouz
1
790
デジタル・デザイン構想 by Sayaka Ishizuka
y150saya
0
190
小さいから、全部わかる。— 常駐AI "xangi" のすすめ
sugupoko
0
270
LiDAR SLAMの実装とセンサ融合 ~Lie群からContinuous-Time LIOまで~
naokiakai
1
990
Kotlin 開発のツラミを爆破した話! / Explode the difficulty of Kotlin dev!
eller86
0
150
事業価値を⽣み出すSREへ SREが担うべき意思決定の5層
kenta_hi
1
1.2k
Featured
See All Featured
Balancing Empowerment & Direction
lara
6
1.2k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
55k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Become a Pro
speakerdeck
PRO
31
6k
Product Roadmaps are Hard
iamctodd
55
12k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.7k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Transcript
GraphQL Radoslav Stankov 15/08/2015
Radoslav Stankov @rstankov http://rstankov.com http://blog.rstankov.com http://github.com/rstankov
None
None
None
None
https://github.com/rstankov/it-tour
None
None
None
None
None
GET /api/events/15/sessions { id: 175, start_at: "11:00", title: "GraphQL", speaker_id:
1, track: 2, }
None
None
GET /api/speakers/1 { id: "1", name: "Radoslav Stankov" }
Rest Client Rest Server
Rest Client Rest Server /api/event/15/sessions
Rest Client Rest Server /api/event/15/sessions /api/speakers/{x} (for 13 speakers)
Rest Client Rest Server /api/event/15/sessions /api/speakers/{x} (for 13 speakers)
…approach 2
GET /api/events/15/sessions { id: 175, start_at: "11:00", title: "GraphQL", track:
2, speaker: { id: 1, name: "Radoslav Stankov" } }
None
None
None
None
None
GET /api/events/15/sessions { id: 175, start_at: "11:00", title: "GraphQL", track:
2, speaker: { id: 1, name: "Radoslav Stankov", photo: "/speaker/photo/1/thumb.jpg" } }
…but over time
{ id: 175, start_at: "11:00", title: "GraphQL", track: 2, description:
"... stuff about Rado", speaker: { id: 1, name: "Radoslav Stankov", photo: "/speaker/photo/1/thumb.jpg", big_photo: "/speaker/photo/1/big.jpg", description: "... stuff about Rado", links: [ "http://rstankov.com", "http://blog.rstankov.com", "http://producthunt.com", ], GET /api/events/15/sessions
id: 175, start_at: "11:00", title: "GraphQL", track: 2, description: "...
stuff about Rado", speaker: { id: 1, name: "Radoslav Stankov", photo: "/speaker/photo/1/thumb.jpg", big_photo: "/speaker/photo/1/big.jpg", description: "... stuff about Rado", links: [ "http://rstankov.com", "http://blog.rstankov.com", "http://producthunt.com", ], alabla1: "foo bar", alabla2: "foo bar", alabla3: "foo bar" }, alabla1: "foo bar", alabla2: "foo bar", alabla3: "foo bar" } GET /api/events/15/sessions
None
…approach 3
None
Rest Client Rest Server
Rest Client Rest Server endpoint 1 feature 1
Rest Client Rest Server endpoint 1 feature 1 endpoint 2
feature 2
Rest Client Rest Server endpoint 1 feature 1 endpoint 2
feature 2 endpoint 3 feature 3
Rest Client Rest Server endpoint 1 feature 1 endpoint 2
feature 2 endpoint 3 feature 3 endpoint N feature N
None
None
None
None
{ id: 175, start_at: "11:00", title: "GraphQL", track: 2, speaker:
{ id: 1, name: "Radoslav Stankov", photo: "/speaker/photo/1/thumb.jpg" } }
{ id start_at title track speaker: { id name photo
} }
None
GET /graphql Request Body Response Body
{ event(id: 15) { sessions { id start_at title
track speaker { id name picture } } } } GET /graphql Request Body Response Body
{ event(id: 15) { sessions { id start_at title
track speaker { id name picture } } } } GET /graphql Request Body Response Body
{ event(id: 15) { sessions { id start_at title
track speaker { id name picture } } } } { "data": { "event": { "sessions": [{ "id": 175, "start_at": "11:00", "title": "GraphQL", "track": 2, "speaker": { "id": 1, "name": "Rado", "picture": null } }] } } } GET /graphql Request Body Response Body
It is that simple
https://facebook.github.io/graphql
GraphQL is a query language created by Facebook in 2012
which provides a common interface between the client and the server for data fetching and manipulations. The client asks for various data from the GraphQL server via queries.
Architecture GraphQL Library (Per-Language) Type Definitions Application
Code
GraphQL • Single endpoint • Not just a library •
Application-Layer Protocol • Server agnostic • Strongly-typed • Client-specified queries • Hierarchical
Tries to solve • N+1 API queries • API response
bloat • Documentation • Ad Hoc Endpoints • Structure issues
https://facebook.github.io/react
https://facebook.github.io/relay
None
Query { event(id: 15) { sessions { id start_at
title track speaker { id name picture } } } }
Query { event(id: 15) { sessions { id start_at
title track speaker { id name picture } } } } { "data": { "event": { "sessions": [{ "id": 175, "start_at": "11:00", "title": "GraphQL", "track": 2, "speaker": { "id": 1, "name": "Rado", "picture": null } }] } } }
Mutation mutation RootMutationType { createSpeaker(name: "Rado") { id }
} { "data": { "createSpeaker": { "id": 2 } } }
Documentation { __schema { types { name fields {
name type { name kind ofType { name kind } } } } } } { "data": { "__schema": { "types": [{ "name": "RootQueryType", "fields": [ { "name": "events", "type": { "name": null, "kind": "LIST", "ofType": { "name": "Event", "kind": "OBJECT" } } }, { "name": "event", "type": {
{ id start_at title track speaker: { id name smallPhoto:
photo(size: 100) bigPhoto: photo(size: 400) } } Cool tricks
query withFragments { user(id: 4) { friends(first: 10) { ...friendFields
} mutualFriends(first: 10) { ...friendFields } } } fragment friendFields on User { id name profilePic(size: 50) } Cool tricks
Demo
Issues • New, just a draft specification • No reliable
graphql server libraries, yet • No reliable graphql client libraries, yet • Mutations are weird • Best practices and solutions • Large datasets
None
None
http://jsonapi.org/
{ "links": { "self": "http://example.com/events/15/sessions", "next": "http://example.com/events/15/sessions?page[offset]=2", "last": "http://example.com/events/15/sessions?page[offset]=10" },
"data": [{ "type": "sesssion", "id": "175", "attributes": { "title": "GraphQL", "track": "2", "start_at": "11:00" }, "relationships": { "speaker": { "links": { "self": "http://varnaconf.com/sessions/175/relationships/speaker", "related": "http://varnaconf.com/speaker/1" }, "data": { "type": "speaker", "id": "1" } }, }, "links": { "self": "http://example.com/sessions/175" } }],
"attributes": { "title": "GraphQL", "track": "2", "start_at": "11:00" }, "relationships":
{ "speaker": { "links": { "self": "http://varnaconf.com/sessions/175/relationships/speaker", "related": "http://varnaconf.com/speaker/1" }, "data": { "type": "speaker", "id": "1" } }, }, "links": { "self": "http://example.com/sessions/175" } }], "included": [{ "type": "speaker", "id": "1", "attributes": { "name": "Radoslav Stankov", "picture": "/photos/1/small.jpg", }, "links": { "self": "http://varnaconf.com/speaker/1" } }]
https://speakerdeck.com/rstankov/graphql
https://github.com/rstankov/talks-code
None
None
@rstankov Thanks :)
Questions?