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
PractiQL GraphQL
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Alexander Savin
December 03, 2015
Technology
0
170
PractiQL GraphQL
Talk performed at AsyncJS meetup in Brighton on 3.12.2015
Alexander Savin
December 03, 2015
Tweet
Share
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
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
150
CDKで始めるTypeScript開発のススメ
tsukuboshi
1
370
SREチームをどう作り、どう育てるか ― Findy横断SREのマネジメント
rvirus0817
0
110
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
160
Digitization部 紹介資料
sansan33
PRO
1
6.8k
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
68k
Bedrock PolicyでAmazon Bedrock Guardrails利用を強制してみた
yuu551
0
190
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
620
StrandsとNeptuneを使ってナレッジグラフを構築する
yakumo
1
100
顧客の言葉を、そのまま信じない勇気
yamatai1212
1
350
GSIが複数キー対応したことで、俺達はいったい何が嬉しいのか?
smt7174
3
150
AWS Network Firewall Proxyを触ってみた
nagisa53
0
210
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
210
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
140
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Ethics towards AI in product and experience design
skipperchong
2
190
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Believing is Seeing
oripsolob
1
53
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Into the Great Unknown - MozCon
thekraken
40
2.3k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
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