Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PractiQL GraphQL
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Alexander Savin
December 03, 2015
Technology
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PractiQL GraphQL
Talk performed at AsyncJS meetup in Brighton on 3.12.2015
Alexander Savin
December 03, 2015
More Decks by Alexander Savin
See All by Alexander Savin
Practical GraphQL with speaker notes
asavin
0
120
Other Decks in Technology
See All in Technology
AI駆動開発で仕様はどこまで書くべきか? ― 人とAIの責務境界から考える開発プロセスの実践
takahiromatsui
1
290
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
220
『GOエコノミー 』(相乗りサービス) におけるスペック駆動開発
mot_techtalk
1
170
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
140
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
16
120k
20260929_AmazonGuardDutyの検出通知メールにAWS DevOpsAgentの調査結果を追加する
yhana
1
410
【Findyテック文化祭ワークショップ】新卒エンジニア&採用担当と作る、 なりたい姿と今やるべき一歩
dip_tech
PRO
0
150
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
3
310
ビジネスを止めない技術的負債の返済のための戦略とその手法 - 技術的負債と向き合う / Complexity and Simplicity
soudai
PRO
2
390
FinTech 1-2 : Overview of FinTech
ks91
PRO
0
120
Incremental HTTP
kazuho
5
1.9k
個別開発で終わらせない。 現場の課題をプロダクトの強さに変える StockmarkのFDE
ktkrhr
0
530
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.2k
Fireside Chat
paigeccino
43
4k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
840
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Transcript
PRACTIQL GRAPHQL
ABOUT ME Alexander Savin Web developer @ Red Badger
Skydiver
REACT LONDON MEETUP > 2000 members
None
GRAPHQL
REAL LIFE STORY
FRONT END APP SERVICE A SERVICE C SERVICE B SERVICE
D
FACEBOOK CASE
GRAPHQL
GRAPHQL SERVER
GRAPHQL SERVER GRAPHQL CLIENT
CLIENT 1.CREATES GRAPHQL QUERY STRING 2.SENDS IT TO THE SERVER
SERVER 1.PROCESSES GRAPHQL QUERY STRING 2.SENDS JSON RESPONSE
LANGUAGE FOR READ / WRITE ACTIONS
QUERIES
{ user { name } }
{ user { name } } { “user”: { “name”:
“Alex Savin” } } GraphQL JSON
MUTATIONS
mutation AddUser { createUser(input: {first_name: "Alex" }) { } }
mutation AddUser { createUser(input: {first_name: "Alex" }) { changedUser {
first_name } } }
QUERY ARGUMENTS
{ user { name } }
{ user(id: 123456) { name } }
NESTING
{ user(id: 123456) { name friends { name } }
}
{ user(id: 123456) { name friends { name friends {
name friends {…} } } } }
COMPOSITION
{ user(id: 123456) { first_name last_name email twitter town homepage
} }
{ user(id: 123456) { …UserDetails } } fragment UserDetails on
User { first_name last_name email twitter town homepage }
TYPE SYSTEM (SERVER)
type User { name: String id: String! }
type User { name: String id: String! } TYPE ROOT
QUERY type Query { user(id: String!): User }
THAT’S ALL YOU NEED (time for live demo)
None
INTROSPECTION
{ __schema { types { fields { name description }
} } }
FEW IMPORTANT TAKEOUTS
DATA SHAPE EQUALITY What you request is what you get
WYRIWYG
NO OVERFETCHING
SINGLE REQUEST / RESPONSE FOR A CLIENT
BACK TO REST
{ "created_at": "2015-08-30T00:50:25.000+00:00", "genres": [], "id": "e66637db-13f9-4056-abef-f731f8b1a3c7", "like_count": 3, "liked_count":
3, "name": "Excuse me while I kiss these frets", "owner": { "avatar_url": "https://secure.gravatar.com/avatar/ 4ede0ad35bb796ea8f78861acc4372ca?s=300", "bio": null, "id": "b06e671a-b169-45e6-a645-74c31abca910", "login": "playlistrock",
{ "created_at": "2015-08-30T00:50:25.000+00:00", "genres": [], "id": "e66637db-13f9-4056-abef-f731f8b1a3c7", "like_count": 3, "liked_count":
3, "name": "Excuse me while I kiss these frets", "owner": { "avatar_url": "https://secure.gravatar.com/avatar/4ede0ad35bb796ea8f78861acc4372ca?s=300", "bio": null, "id": "b06e671a-b169-45e6-a645-74c31abca910", "login": "playlistrock", "name": "Playlist Rock", "site_admin": false }, "published": false, "saved_count": 3, "tags": [ { "name": "Jimi Hendrix" }, { "name": "Jimmy Page" }, { "name": "Eric Clapton" }, … https://blog.jacobwgillespie.com/from-rest-to-graphql-b4e95e94c26b
GRAPHQL IS A SPEC http://facebook.github.io/graphql/
EXPRESS GRAPHQL DEMO
RESOLVE {}
ASYNC RESOLVE {}
async resolve(obj, {...}) { const endpoints = [ { endpoint:
'voiceNumber', data: contactNumber }, { endpoint: 'smsNumber', data: contactNumber }, { endpoint: 'email', data: email }, ]; const processEndpoint = async ({endpoint, data}) => { try { return await contactService[endpoint](data); } catch (error) { return error; } }; const processes = [
const processes = [ for (process of endpoints) processEndpoint(process) ];
const responses = await* processes; const errors = responses.filter(response => response instanceof Error); if (errors.length) { throw errors; } return { accessToken, refreshToken, };
RELAY
None
REUSABLE SELF-CONTAINED COMPONENTS
myComponent\ index.js style.css test.js data?
OPTIMISTIC UPDATES ERROR HANDLING OPTIMAL DATA FETCHING
COMPONENTS DECLARE WHAT DATA THEY NEED
None
Relay with React Native Allows code re-usability across iOS and
Android 87% in case of this app
GRAPHQL
GRAPHQL RELAY REACT FLUX
BACK TO OUR STORY
FRONT END APP SERVICE A SERVICE C SERVICE B SERVICE
D
FRONT END APP SERVICE A SERVICE C SERVICE B SERVICE
D GRAPHQL SERVER
FRONT END APP SERVICE A SERVICE C SERVICE B SERVICE
D GRAPHQL SERVER IOS ANDROID
FRONT END APP SERVICE A SERVICE C SERVICE B SERVICE
D GRAPHQL SERVER IOS ANDROID FRONT END APP V2 IOS V2 ANDROID V2
FRONT END APP GRAPHQL SERVER IOS ANDROID FRONT END APP
V2 IOS V2 ANDROID V2
THANKS
Alexander Savin @karismafilms Red Badger @redbadgerteam
REFERENCES • http://red-badger.com/blog/2015/08/28/give-it-5-days-facebook-relay-and-graphql/ • http://red-badger.com/blog/2015/07/09/graphql-and-the-open-movie-database-from- introspection-to-inception/ • https://blog.jacobwgillespie.com/from-rest-to-graphql-b4e95e94c26b • https://www.youtube.com/watch?v=Ed6oJXKt3-M
- Nick Schrock on GraphQL • http://graphql.org/ • https://www.reindex.io/ • http://radiobadger.com/posts/2015-11-05-episode-26.html