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
Amplify Meetup #01
Search
Taewoo Kim
July 31, 2020
Programming
1
6.4k
Amplify Meetup #01
AWS Amplify Meetup #01 で LT 発表したスライドです。
Taewoo Kim
July 31, 2020
Tweet
Share
More Decks by Taewoo Kim
See All by Taewoo Kim
AWS Lambda 내부동작 파헤치기
twkiiim
1
2.6k
Amazon VPC Deep Dive: ENI 를 알면 VPC 가 보인다
twkiiim
2
5.4k
온라인 주문 서비스를 서버리스 아키텍쳐로 구축하기
twkiiim
0
390
Amazon EventBridge vs Amazon SNS
twkiiim
0
2.2k
活用パターンで学ぶGraphQL
twkiiim
0
1.3k
AWS 기반 서버리스 아키텍쳐 톺아보기
twkiiim
0
2k
AWS 기반 서버리스 아키텍쳐 톺아보기
twkiiim
1
3k
AppSync를 활용한 리얼타임 서버리스 아키텍쳐
twkiiim
0
4.4k
[LINE API × Tech API Vol. 2 Powered by AWS] サーバーレスでの分散トランザクション
twkiiim
0
2.3k
Other Decks in Programming
See All in Programming
PHPカンファレンス 2024|共創を加速するための若手の技術挑戦
weddingpark
0
140
最近のVS Codeで気になるニュース 2025/01
74th
1
210
20241217 競争力強化とビジネス価値創出への挑戦:モノタロウのシステムモダナイズ、開発組織の進化と今後の展望
monotaro
PRO
0
310
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
2k
Swiftコンパイラ超入門+async関数の仕組み
shiz
0
180
[JAWS-UG横浜 #79] re:Invent 2024 の DB アップデートは Multi-Region!
maroon1st
0
100
月刊 競技プログラミングをお仕事に役立てるには
terryu16
1
1.2k
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
110
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
28
4.4k
Beyond ORM
77web
11
1.6k
Amazon Nova Reelの可能性
hideg
0
230
テストコード書いてみませんか?
onopon
2
350
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
250
What's in a price? How to price your products and services
michaelherold
244
12k
Fireside Chat
paigeccino
34
3.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Thoughts on Productivity
jonyablonski
68
4.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
580
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
4
190
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
A designer walks into a library…
pauljervisheath
205
24k
How STYLIGHT went responsive
nonsquared
96
5.3k
Transcript
AmplifyͷAPIػೳΛ͏ࡍͷTips Amplify Meetup #01 LT ηογϣϯ #05
ࣗݾհ • Taewoo Kim (ΩϜςʣɺؖࠃਓͰ͢ʂ • AWS Solutions Architect at
• 2020 APN AWS Top Engineers ʹબ • ͖ͳAWSαʔϏε AWS AppSync ͱ AWS Amplify
ຊηογϣϯͷର • AWS Amplify API ػೳΛҰͰ࣮ࡍʹࢼͯ͠Έͨํ • AWS Amplify νϡʔτϦΞϧΛΫϦΞʔͨ͠ํ
• AWS Amplify Λຊ൪ڥͰಋೖ͍ͨ͠ͱࢥ͏ํ
ૣͰ͕͢
օ͞Μ Amplifyͳͥͬͯ·͔͢ʁ
AmplifyΛ͏ཧ༝ • ָ͍͔͠Β • όοΫΤϯυଆͷ࣮ศརͩ͠ɺϑϩϯτଆͷָ࣮ʹͳΔ͔Β •ϏδωεΞΠσΟΞΛ۩ମԽͨ͠ॳظMVPΛ രͰ࣮Ͱ͖Δ͔Βʂ
AmplifyΛ͏ཧ༝ • ָ͍͔͠Β • όοΫΤϯυଆͷ࣮ศརͩ͠ɺϑϩϯτଆͷָ࣮ʹͳΔ͔Β •ϏδωεΞΠσΟΞΛ۩ମԽͨ͠ॳظMVPΛ രͰ࣮Ͱ͖Δ͔Βʂ
AmplifyΛ͏ཧ༝ • ָ͍͔͠Β • όοΫΤϯυଆͷ࣮ศརͩ͠ɺϑϩϯτଆͷָ࣮ʹͳΔ͔Β •ϏδωεΞΠσΟΞΛ۩ମԽͨ͠ॳظMVPΛ രͰ࣮Ͱ͖Δ͔Βʂ ݸਓతʹ͜ͷཧ༝(↑)͕Ұ൪େࣄͩͱࢥ͍·͢
AmplifyΛ͏ཧ༝ • ָ͍͔͠Β • όοΫΤϯυଆͷ࣮ศརͩ͠ɺϑϩϯτଆͷָ࣮ʹͳΔ͔Β •ϏδωεΞΠσΟΞΛ۩ମԽͨ͠ॳظMVPΛ രͰ࣮Ͱ͖Δ͔Βʂ ݸਓతʹ͜ͷཧ༝(↑)͕Ұ൪େࣄͩͱࢥ͍·͢ MVP࣮ͰAmplify͕Ұ൪ʹཱͭػೳ API
Amplify API Λ͍࢝Ίͨࡍʹ ඞ͓͍ͣͬͯͨํ͕ྑ͍ ϊϋΛڞ༗͠·͢
όοΫΤϯυϓϩδΣΫτ ϑϩϯτ͔Βͨ͠ํ͕ྑ͍
Ϟνϕʔγϣϯ • Amplify ެࣜυΩϡϝϯτΛݟΔͱɺϑϩϯτΤϯυϓϩδΣΫτͰ όοΫΤϯυϓϩδΣΫτΛҰॹʹཧ͢Δํ๏Λհ͍ͯ͠·͢ɻ • ͭ·ΓɺϑϩϯτΤϯυϓϩδΣΫτͷதʹɺamplify/ ͱ͍͏ϑΥ ϧμʔ͕ଘࡏ͢Δͱ͍͏ܗʹͳΓ·͢ɻ •
Ͱ͕͢ɺෳͷϓϩδΣΫτͰߏ͞Εͨ߹ɺ֤ϓϩδΣΫτʹ όοΫΤϯυઃఆΛೖΕΔͷ͕ਖ਼͍͠ͷ͔ɺͱ͍͏Έ͕͔ͪͱࢥ͍ ·͢ɻ
Ϟνϕʔγϣϯ • Amplify ެࣜυΩϡϝϯτΛݟΔͱɺϑϩϯτϓϩδΣΫτͰόο ΫΤϯυϓϩδΣΫτΛҰॹʹཧ͢Δํ๏Λհ͍ͯ͠·͢ɻ • ͭ·ΓɺϑϩϯτΤϯυϓϩδΣΫτͷதʹɺamplify/ ͱ͍͏ ϑΥϧμʔ͕ଘࡏ͢Δͱ͍͏ܗʹͳΓ·͢ɻ •
Ͱ͕͢ɺෳͷϓϩδΣΫτͰߏ͞Εͨ߹ɺ֤ϓϩδΣΫτ ʹόοΫΤϯυઃఆΛೖΕΔͷ͕ਖ਼͍͠ͷ͔ɺͱ͍͏Έ͕͔ͪͱ ࢥ͍·͢ɻ ͏Μ….. όοΫΤϯυผ్Ͱཧ͠·͠ΐ͏ʂ
όοΫΤϯυϓϩδΣΫτΛ͢Δ͜ͱͰಘΔϝϦοτ 1. όοΫΤϯυͱϑϩϯτͷSeparation of ConcernΛ࣮ݱ͍͢͠ 2. ෳͷϝϯόʔ͕Ұॹʹ࡞ۀ͘͢͠ͳΔ 3. কདྷతʹόοΫΤϯυϓϩδΣΫτΛϚΠάϨʔγϣϯ͢Δʹ ͬͱָʹͳΔ
όοΫΤϯυͱϑϩϯτΤϯυ͠·͠ΐ͏ʂ https://dev.classmethod.jp/articles/amplify-tips-series-1/
GraphQL Schemaͷ type ʹ @model Λ͚ͳ͔ͬͨ࣌ͷ ҙ͖͢͜ͱ
GraphQL Schemaͷ type ʹ @model Λ͚ͳ͔ͬͨ࣌ͷҙ͖͢͜ͱ https://dev.classmethod.jp/articles/amplify-tips-series-3/
ͦͦ @model Λͳ͚ͥͭͳ͍ΜͰ͔͢ʁʁ @model σΟϨΫςΟϒΛ͚ͭΔ͜ͱͷϝϦοτ 1. σʔλιʔε(DynamoDB) Λੜ͠ɺ AppSync ͱ࿈ܞͯ͘͠ΕΔɻ
2. Create/Read/Update/Delete/List ΦϖϨʔγϣϯΛಈ࡞ͤ͞ΔͨΊͷ Query Mutation ͱɺͦΕͧΕ͕ඞཁͱ͢Δ input ͷλΠϓΛࣗಈͰੜͯ͘͠ΕΔɻ 3. ੜ͞Εͨ Query MutationɺλΠϓϑΟʔϧυresolverͷͨΊͷ Request/Response Mapping TemplatesΛࣗಈͰੜͯ͘͠ΕΔɻ 4. ͜ͷΑ͏ʹੜ͞Εͨ CRUD(L) API ΛɺΫϥΠΞϯτιʔείʔυଆͰΞΫηεͰ͖Δ API ϥΠϒϥϦʔΛࣗಈͰੜͯ͘͠ΕΔɻ (amplify codegen)
@connection ͱ depth ͋ͨΓ • యܕతͳΞϓϦσʔλεΩϚʔͰඞཁͳλΠϓ͕ेʙඦ • λΠϓ͝ͱͷؔੑΛ࡞ΔͨΊʹ @connection ͕ඞཁ
• codegen ͷ depth ΛݮΒ͢··ҡ࣋͢ΔͨΊɺˏmodel Λফ͢ • ݁Ռతʹ @connection ແ͠ͰσʔλʹΞΫηεՄೳ
@model Λ͚ͭͳ͔ͬͨࡍͷҙʁ • @model Λ͚ͭͳ͍ͱɺͦͷ DynamoDB ςʔϒϧ͕ੜ͞Εͳ͍ • ଞͷ type
ͷςʔϒϧʹ JSON ܗࣜͰอଘ͞ΕΔ • DynamoDB JSON ෦ͷϑΟʔϧυʹରͯ͠ͷ Query αϙʔτ͠ ͯ͘Ε͍ͯͳ͍
@model Λ͚ͭͳ͔ͬͨࡍͷҙʁ • ͳͷͰɺdepth ͋ͨΓͷΈͰ ˏmodel Λ͚ͭͨ͘ͳ͍ͳΒɺ depth ઃఆؾʹͤͣɺ query
ίʔυΛ࡞͢Εྑ͍ https://dev.classmethod.jp/articles/amplify-tips-series-4/
Custom Resolver ͷ໋໊نଇΛ ઌʹܾΊΑ͏
Custom Resolver ͕ඞཁͷ߹ͬͯʁ • ECαΠτͷจAPIɿ - ܾࡁαʔϏεͱจαʔϏεͷ࿈ܞ - ใαʔϏεͱσϦόϦʔαʔϏε -
શͯΛ߹ΘͤͯτϥϯβΫγϣϯॲཧ • SNSͷྑ͍Ͷʂɿ - ୭͔ྑ͍Ͷʂ͔ͨ͠ʢϢʔβʔςʔϒϧʣ - ྑ͍Ͷʂͷτʔλϧ - ߘσʔλςʔϒϧ - શͯ߹ΘͤͯτϥϯβΫγϣϯॲཧ
schema.graphql
custom_resolver.yaml 1 2 3
custom_resolver.yaml
custom_resolver.yaml
custom_resolver.yaml
VTL ϑΝΠϧ Query.myCustomLambdaExecution.req.vtl
Custom Resolver ʹ͍ͭͯͷࢲͷߟ͑ • ϓϩδΣΫτͰඞཁͳ Custom Resolver ͕ݸఔͳΒແ͠ • ϓϩδΣΫτͰඞཁͳ
Custom Resolver ͕ेݸҎ্ͳΒɺ Custom Resolver ͷཧίετ։ൃίετ͕ߴ͘ͳΔ • ͬͱָʹ͢Δʹ Serverless Framework ͷ serverless-appsync- plugin Λར༻ͯ͠ AppSync Λߏங͢Δ → amplify codegen Ͱ͖Δ͠ɺcustom resolver ͷָ࣮ʹͳΔ → ͰɺAmplify ͷ σΟϨΫςΟϒ͑ͳ͍
ϒϩάಡΜͰΈ͍ͯͩ͘͞ :D
https://dev.classmethod.jp/tag/aws-amplify/
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ