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
300
0
Share
REST脳脱出のためのGraphQLの命名の話
asmsuechan
December 19, 2018
More Decks by asmsuechan
See All by asmsuechan
入門: マークダウン
asmsuechan
0
14k
Featured
See All Featured
We Are The Robots
honzajavorek
0
210
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
170
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Amusing Abliteration
ianozsvald
1
150
Measuring & Analyzing Core Web Vitals
bluesmoon
9
800
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
280
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
170
Designing Experiences People Love
moore
143
24k
Leo the Paperboy
mayatellez
6
1.6k
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 ※͜ΕࢲͷࢦͰ͋ͬͯղͰ͋Γ·ͤΜ
ऴ