AppSync入門できなかったのでGraphQLに入門した

7560933eeba917db748c562b05fea3a3?s=47 sin-tanaka
September 21, 2018

 AppSync入門できなかったのでGraphQLに入門した

2018/9/21 JAWS-UG長野でのLT

【2018 秋の部】AWS Cloud Express Roadshow in 長野 後夜祭
https://jawsug-nagano.connpass.com/event/99668/

7560933eeba917db748c562b05fea3a3?s=128

sin-tanaka

September 21, 2018
Tweet

Transcript

  1. 3.

    AppSync • 4݄ʹҰൠެ։ • GraphQLϚωʔδυαʔϏε • HTTP(S)ϦΫΤετΛड͚ͯAWSαʔϏεʢLambda, DynamoDB, ElasticSearchʣʹͭͳ͗͜Έ͕Ͱ͖Δ •

    GraphQLͷεΩʔϚఆٛ • ΫΤϦΛࢼͤΔίϯιʔϧ෇͖ • GraphQLͷSubscriptionͱ͍͏࢓૊ΈΛ࢖ͬͯσʔλͷมߋΛ ݕ஌ˠը໘΁ͷ൓ө·Ͱग़དྷΔ
  2. 14.

    ాத ৻ଠ࿠(@_sin_tanaka) ʢגʣ೔ຊγεςϜٕݚ / GeekLab.NAGANO ελοϑ GitHub / Medium: @sin_tanaka

    Իָͱਂ໷ϥδΦ͕޷͖ serverless-wsgi ʹϓϧϦΫग़ͨ͠Γͨ͠ PyCon JP 2018 ͰτʔΫηογϣϯ ← NEW!!
  3. 16.
  4. 19.

    GraphQLͷ࢖͍ํ 1 type Query { 2 me: User 3 }

    4 5 type User { 6 id: ID 7 name: String 8 } 9 foo.scheme εΩʔϚ: αʔό΍ϚωʔδυαʔϏεଆʹఆٛ͢Δ
  5. 20.

    GraphQLͷ࢖͍ํ 1 { 2 me { 3 name 4 }

    5 } ΫΤϦ: ΫϥΠΞϯτଆ͔Β౤͛Δσʔλ 1 { 2 "me": { 3 "name": "Luke Skywalker" 4 } 5 } https://hogehoge.com/graphql?{me{name}}
  6. 25.

    Query • ྫ: type Query { allUser(id: Int, first: Int):

    [User] getUser(role: String) me: User } type User { id: ID name: String } foo.scheme
  7. 27.

    Query - Alias • ྫ: ಉ͡ΫΤϦ͕ෳ਺͋Δͷ͸μϝͳͷͰAliasΛ࢖͏ { getUser(role: admin) {

    id firstName lastName phone username } getUser(role: accountant) { id firstName lastName phone username } }
  8. 28.

    Query - Alias • ྫ: ಉ͡ΫΤϦ͕ෳ਺͋Δͷ͸μϝͳͷͰAliasΛ࢖͏ { admins: getUser(role: admin)

    { id firstName lastName phone username } accountants: getUser(role: accountant) { id firstName lastName phone username } }
  9. 29.

    Query - Fragment • ྫ: ·ͱΊ͍ͨ৔߹ { admins: getUser(role: admin)

    { id firstName lastName phone username } accountants: getUser(role: accountant) { id firstName lastName phone username } }
  10. 30.

    Query - Fragment • ྫ: ·ͱΊ͍ͨ৔߹ { admins: getUser(role: admin)

    { …user } accountants: getUser(role: accountant) { …user } } fragment user on User { id firstName lastName phone username }
  11. 31.

    Mutation • ࡞੒ / มߋ΋εΩʔϚʹఆٛ͢Δ type Mutation { createReview(episode: String,

    review): Review } mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) { createReview(episode: $ep, review: $review) { stars commentary } } ΫΤϦ
  12. 34.

    GraphQL vs REST? • REST • endpoint͕ෳ਺ • ԿΛͲ͏ฦ͔͢͸αʔό͕ܾΊΔ •

    GraphQL • endpoint͕୯Ұ • ԿΛͲ͏ฦ͔͢͸ΫϥΠΞϯτ͕ܾΊΔ