Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Amplify Meetup #01

Amplify Meetup #01

AWS Amplify Meetup #01 で LT 発表したスライドです。

Taewoo Kim

July 31, 2020
Tweet

More Decks by Taewoo Kim

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • Taewoo Kim (ΩϜς΢ʣɺؖࠃਓͰ͢ʂ • AWS Solutions Architect at

    • 2020 APN AWS Top Engineers ʹ౰બ • ޷͖ͳAWSαʔϏε͸ AWS AppSync ͱ AWS Amplify
  2. Ϟνϕʔγϣϯ • Amplify ެࣜυΩϡϝϯτΛݟΔͱɺϑϩϯτϓϩδΣΫτͰόο ΫΤϯυϓϩδΣΫτΛҰॹʹ؅ཧ͢Δํ๏Λ঺հ͍ͯ͠·͢ɻ • ͭ·ΓɺϑϩϯτΤϯυϓϩδΣΫτͷதʹɺamplify/ ͱ͍͏ ϑΥϧμʔ͕ଘࡏ͢Δͱ͍͏ܗʹͳΓ·͢ɻ •

    Ͱ͕͢ɺෳ਺ͷϓϩδΣΫτͰߏ੒͞Εͨ৔߹͸ɺ֤ϓϩδΣΫτ ʹόοΫΤϯυઃఆΛೖΕΔͷ͕ਖ਼͍͠ͷ͔ɺͱ͍͏೰Έ͕͔ͪͱ ࢥ͍·͢ɻ ͏Μ….. όοΫΤϯυ͸ผ్Ͱ؅ཧ͠·͠ΐ͏ʂ
  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)
  4. @connection ͱ depth ͋ͨΓ • యܕతͳΞϓϦ͸σʔλεΩϚʔͰඞཁͳλΠϓ਺͕਺ेʙ਺ඦ • λΠϓ͝ͱͷؔ܎ੑΛ࡞ΔͨΊʹ @connection ͕ඞཁ

    • codegen ͷ depth ΛݮΒ͢··ҡ࣋͢ΔͨΊɺˏmodel Λফ͢ • ݁Ռతʹ @connection ແ͠Ͱ΋௚઀σʔλʹΞΫηεՄೳ
  5. @model Λ͚ͭͳ͔ͬͨࡍͷ஫ҙ఺͸ʁ • @model Λ͚ͭͳ͍ͱɺͦͷ DynamoDB ςʔϒϧ͕ੜ੒͞Εͳ͍ • ଞͷ type

    ͷςʔϒϧʹ JSON ܗࣜͰอଘ͞ΕΔ • DynamoDB ͸ JSON ಺෦ͷϑΟʔϧυʹରͯ͠ͷ Query ͸αϙʔτ͠ ͯ͘Ε͍ͯͳ͍
  6. @model Λ͚ͭͳ͔ͬͨࡍͷ஫ҙ఺͸ʁ • ͳͷͰɺdepth ͋ͨΓͷ೰ΈͰ ˏmodel Λ͚ͭͨ͘ͳ͍ͳΒ͹ɺ
 depth ઃఆ͸ؾʹͤͣɺ௚઀ query

    ίʔυΛ࡞੒͢Ε͹ྑ͍
 
 
 
 
 
 
 
 
 
 https://dev.classmethod.jp/articles/amplify-tips-series-4/
  7. Custom Resolver ͕ඞཁͷ৔߹ͬͯʁ • ECαΠτͷ஫จAPIɿ
 - ܾࡁαʔϏεͱ஫จαʔϏεͷ࿈ܞ
 - ঎඼৘ใαʔϏεͱσϦόϦʔαʔϏε
 -

    શͯΛ߹ΘͤͯτϥϯβΫγϣϯॲཧ • SNSͷྑ͍Ͷʂɿ
 - ୭͔ྑ͍Ͷʂ͔ͨ͠ʢϢʔβʔςʔϒϧʣ
 - ྑ͍Ͷʂͷτʔλϧ਺
 - ౤ߘσʔλςʔϒϧ
 - શͯ߹ΘͤͯτϥϯβΫγϣϯॲཧ
  8. Custom Resolver ʹ͍ͭͯͷࢲͷߟ͑ • ϓϩδΣΫτ಺Ͱඞཁͳ Custom Resolver ͕਺ݸఔ౓ͳΒ໰୊ແ͠ • ϓϩδΣΫτ಺Ͱඞཁͳ

    Custom Resolver ͕਺ेݸҎ্ͳΒɺ
 Custom Resolver ͷ؅ཧίετ΍։ൃίετ͕ߴ͘ͳΔ • ΋ͬͱָʹ͢Δʹ͸ Serverless Framework ͷ serverless-appsync- plugin Λར༻ͯ͠ AppSync Λߏங͢Δ
 → amplify codegen ΋Ͱ͖Δ͠ɺcustom resolver ͷ࣮૷΋ָʹͳΔ
 → Ͱ΋ɺAmplify ͷ σΟϨΫςΟϒ͸࢖͑ͳ͍