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
REST脳脱出のためのGraphQLの命名の話
Search
asmsuechan
December 19, 2018
0
290
REST脳脱出のためのGraphQLの命名の話
asmsuechan
December 19, 2018
Tweet
Share
More Decks by asmsuechan
See All by asmsuechan
入門: マークダウン
asmsuechan
0
14k
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
35
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
1
340
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
190
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
94
Believing is Seeing
oripsolob
0
19
Code Review Best Practice
trishagee
74
19k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Visualization
eitanlees
150
16k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
A designer walks into a library…
pauljervisheath
210
24k
Transcript
RESTग़ͷͨΊͷ໋໊ͷ asmsuechan
asmsuechan ࣗ ݾ հ 0 ݸਓϓϩμΫτͱ͔ͰGraphQLͬͯΔ ϑϩϯτɺαʔόʔɺͪΐͬͱΫϥυ Alibaba Cloud
MVP
GraphQLͷ໊લ͚ ࠓ ͢ ͜ ͱ “GraphQLͬΆ͍”໊લʹ ͢ΔͨΊʹࢲ͕ҙ͍ࣝͯ͠Δ͜ͱ 1
querymutationͷ໊લͷ
(1) queryͷ߹ ݁ ໊લͷཪʹόοΫΤϯυͷಈ࡞͕ݟ͑Δ 2.1 REST ໊લͷཪʹཉ͍͠σʔλ͕ݟ͑Δ GraphQL ͿͬͪΌ͚queryͷ໋໊RESTͱ͋·Γ͕ࠩͳ͍ؾ͢Δ
σʔλΛऔͬͯ͘Δͭ
(1) GET: /users/:idΛqueryʹ͢Δ ྫ ͑ getUser(id: $id) { email
name } (ਖ਼͜ΕશવڐͤΔ) ϢʔβʔΛใΛදࣔ͢ΔͨΊͷΤϯυϙΠϯτ 2.1 user(id: $id) { email name } X O ???ʮԶgetUser͍ͨ͠Μ͡Όͳͯ͘userͷใ͕ཉ͍͠ΜͩΑʯ
(2) mutationͷ߹ ݁ ໊લͷཪʹϦιʔε͕ݟ͑Δ 2.2 REST ໊લͷཪʹৼΔ͍͕ݟ͑Δ GraphQL ※Ϧιʔε:
αʔόʔͰऔΓѻΘΕΔσʔλͷҙ ※ৼΔ͍: ΫϥΠΞϯτͰϢʔβʔ͕࣮ߦ͢Δಈ࡞ͷҙ σʔλΛߋ৽͢Δͭ
ྫ ͑ (2) POST: /users/:id/followΛmutationʹ͢Δ mutation createFollowee(id: $id) {
user { id name } } mutation follow(id: $id) { user { id name } } FolloweeͬͯϦϨʔγϣϯ͕ݟ͑ͯ͠·͏ “follow”Ͱ1ͭͷৼΔ͍͕ݟ͑Δ (ϢʔβʔΛϑΥϩʔ͢ΔͨΊͷΤϯυϙΠϯτ) ײ͡Δྗ͕େࣄ 2.2 X O
ͳͥ͜Ε͕ྑ͍ͱࢥ͏ͷ͔ ཧ ༝ 3 GraphQLόοΫΤϯυͷσʔλߏΛΒͳ͍ ΫϥΠΞϯτͷ։ൃऀͨͪͷͨΊʹ࡞ΒΕ͔ͨΒ ͭ·Γྺ࢙తഎܠ
ྺ࢙తഎܠ ཧ ༝ 3 ΫϥΠΞϯτ࡞Δਓͱαʔόʔ࡞Δਓผ(ͷͣ) σΧ͍৫ͰෳࡶͳσʔλߏͷαʔϏεΛӡ༻͍ͯ͠Δதɺ σʔλߏΛΒͳ͍ਓͰָʹཉ͍͠σʔλΛऔಘ͍ͨ͠ GraphQLΛ࡞ͬͨͷFacebook
ྺ࢙తഎܠ ཧ ༝ 3 (࣮࢞ͷߘ) • ༑ୡͷߘͷதʹ༑ୡͷ༑ୡͷίϝϯτ͕ݟ͑Δ • ͍͍Ͷʹࣗͷ༑ୡ͕༏ઌදࣔ͞ΕΔ ϦϨʔγϣϯΛ͜Ͷ͘Γճ͍ͯ͠Δ
ྺ࢙తഎܠ ཧ ༝ 3 ϦιʔεAΛऔ͖ͬͯͨΒͦͷidʹج͍ͮͯ ϦιʔεBΛऔ͖ͬͯͯ…. Έ͍ͨͳ͕άνϟάνϟʹଓ͍͍ͯ͘ RESTͰΔͱԿϦΫΤετΛૹΔඞཁ͕͋Δ ͜ΕΛָʹͨͯ͘͠ੜ·Εͨͷ͕GraphQL
ݴ͍͍ͨ͜ͱ ݁ ໊લͷཪʹόοΫΤϯυ͕ݟ͑Δ 5 REST ໊લͷཪʹΫϥΠΞϯτ͕ݟ͑Δ GraphQL ※͜ΕࢲͷࢦͰ͋ͬͯղͰ͋Γ·ͤΜ
ऴ