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.3k
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.3k
온라인 주문 서비스를 서버리스 아키텍쳐로 구축하기
twkiiim
0
380
Amazon EventBridge vs Amazon SNS
twkiiim
0
2.1k
活用パターンで学ぶGraphQL
twkiiim
0
1.3k
AWS 기반 서버리스 아키텍쳐 톺아보기
twkiiim
0
2k
AWS 기반 서버리스 아키텍쳐 톺아보기
twkiiim
1
2.9k
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
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Jakarta EE meets AI
ivargrimstad
0
140
Outline View in SwiftUI
1024jp
1
330
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Arm移行タイムアタック
qnighy
0
320
Jakarta EE meets AI
ivargrimstad
0
530
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
890
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
2
660
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
890
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
Featured
See All Featured
Designing for Performance
lara
604
68k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
A Philosophy of Restraint
colly
203
16k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The Language of Interfaces
destraynor
154
24k
The Pragmatic Product Professional
lauravandoore
31
6.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/
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ