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

AppSync というか GraphQL 設計 Tips 5選

ktsukago
December 14, 2018

AppSync というか GraphQL 設計 Tips 5選

meguro.dev #5の資料です

https://meguro-dev.connpass.com/event/110965/

ktsukago

December 14, 2018
Tweet

More Decks by ktsukago

Other Decks in Technology

Transcript

  1. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Specialist Solutions Architect Tsukagoshi Keisuke 2018/12/14 AppSync הְֲַ GraphQL 鏣鎘 Tips 5鼅 meguro.dev #5
  2. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark عحءُةؚ #meguro_dev
  3. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark Who am I ? 㝩馉 ㉔➜אַ׀׃ ְֽֽׅ 4QFDJBMJTU4PMVUJPO"SDIJUFDU !"NB[PO8FC4FSWJDFT+BQBO .PCJMF%FW0QT4FSWFSMFTT.JDSPTFSWJDFT #BDLHSPVOE ،فٔ؛٦ءّٝꟚ涪 8FC؟٦ؽأךꟚ涪٥麊欽 ٔ،ؙذ؍ـفؚٗٓىؚٝ "HJMFꟚ涪ך؝ٝ؟ٕذ؍ؚٝ 㥨ֹז؟٦ؽأ "QQ4ZOD 㥨ֹז⹛暟 ֲֺׁ
  4. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AppSync הכ
  5. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark AppSync הכ • وط٦آس GraphQL gateway • GraphQL schema definition language (SDL) ח״׷ API 㹀纏 • AWS ٔا٦أ׾ر٦ةا٦أה׃גⵃ欽 • ٔ،ٕة؎ير٦ةـٗ٦ؕ٦ • ر٦ةך刿倜䞔㜠׾؟ـأؙٓ؎ـ • MQTT over WebSocketדךٔ،ٕة؎ير٦ةך鷏⥋
  6. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark AWS AppSync 嚊銲 Http Query / mutation subscription
  7. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark AppSync הכ
  8. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark GraphQL הכ • GraphQLծכAPI 欽ךؙؒٔ鎉铂ד֮׶ծTypeSystem ׾⢪欽׃גؙؒٔ ׾㹋遤ׅ׷׋׭ך؟٦غ٦⩎ךٓٝة؎يדׅկ • GraphQLכծؙٓ؎،ٝزָ؟٦غ٦ַ׵ر٦ة׾《䖤ծ 㢌刿ծ飑铣דֹ׷״ֲחׅ׷׋׭ךر٦ة鎉铂דׅկ { "id": "1", "name": "Get Milk", " priority": "1" }, { "id": “2", "name": “Go to gym", "priority": “5" },… type Query { getTodos: [Todo] } type Todo { id: ID! name: String description: String priority: Int duedate: String } query { getTodos { id name priority } }
  9. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark ז׈ GraphQL זךַ • REST API ךꟚ涪罏ծⵃ欽罏꟦ך铬겗 • API ➬圫ךسًُؗٝز盖椚/ ➬圫ך椚鍑ָ㣐㢌 • API ךسًُؗٝزה㹋鄲ָ׆׸גג؛ٝؕ • ؙٓ؎،ٝزꟚ涪罏ַ׵ך♶弫 • ل٦آ׾邌爙ׅ׷ךח⡦⦐׮ API ׾〨ַזֽ׸לז׵זְ • ׇ׏ַֻ؎كٝزسٔـٝח⡲׏גְג׮؟٦غ٦הך䱸竲כ穠㽷 Request / Responseך䕎ָךֿ׷
  10. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark GraphQL ך⹛ぢ • GraphQL Foundation ָ鏣甧 • Facebook ⪐♴ַ׵ Linux ⪐♴ח • GraphQL ך Design Pattern ָ䖚ղחⰕꟚ • Schema Design Pattern • Data Design Pattern • Testing Practice • CI / CD Practice
  11. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark ֶׅׅ׭项俱 • GraphQL API ך鏣鎘 Tips GraphQL ך鏣鎘׾װ׷ז׵䗳铣 • https://www.slideshare.net/AmazonWebServices/ten-tips-and- tricks-for-improving-your-graphql-api-with-aws-appsync-mob401- aws-reinvent-2018 • https://www.youtube.com/watch?v=CwLB0BRwIqE • չAppSync Mob401պ ד嗚稊
  12. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AppSync 鏣鎘 Tips 5鼅
  13. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark 1. غ٦آّٝ盖椚 • REST הכⴽך䙼䟝ד Versionless API ׾䱿㤺׃גְ׷ • GraphQL כ僇爙涸ח銲実ׁ׸׋ر٦ةך׫׾鵤ׅ׋׭ծ䕦갟׾䫇ִאא倜 ׃ְة؎فװؿ؍٦ٕس׾鷄⸇〳腉 • GraphQL כأؗ٦وך竰竲涸ז鹌⻉ך׋׭ךخ٦ٕ׾䲿⣘ׅ׷ֿהח״׶ծ غ٦آّٝ盖椚׾鼘ֽ׷הְֲ䙼䟝 type ExampleType { newField: String oldField: String @deprecated(reason: "Use `newField`.") }
  14. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark 2. Nullability • non-null / null ׾ֲתֻⵃ欽׃׋鏣鎘ֶָׅׅ׭ • Not-null䱿㤺ך؛٦أ • ؿ؍٦ٕس䒷侧חְֶגծ䒷侧ָזְה䠐㄂׾זׁזְ״ֲז؛٦ כNon-null (⢽ : getRestaurantById(id: ID!) ) • ؔـآؙؑزך㶷㖈ָ⥂鏾ׁ׸׷ؿ؍٦ٕسכNon-null • ؿٗٝزؒٝس؝٦س׾知殛⻉ׅ׷ • Null ׾鏩㺁ׅ׷ךָ䱿㤺ך؛٦أ • 倜鋉ח鷄⸇׃׋ؿ؍٦ٕس䒷侧 • ➙תדזַ׏׋ؿ؍٦ٕس䒷侧׾䗳갭ח׃ג׃תֲהծ䖓倯✼䳔ָ《׸ זֻז׏ג׃תֲ〳腉䚍ָ֮׷׋׭ Null׾鏩㺁ׅ׷ • 3rd Party ך؟٦ؽأה鸬䵿ׅ׷״ֲז؛٦أ • Lookup ח㣟侁׃ֲ׷㜥さכnull ׾鏩〳׃גֶֻ
  15. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark 3. ل٦آط٦ءّٝ query SimplePaginatedQuery { listObjects(limit: 10, nextToken: “…”) { items { id title } nextToken # Finished when null } } # Simple and effective type UserPostConnection { items: [UserPost] nextToken: String } type User { id: ID! posts: UserPostConnection type UserPost { id: ID! content: String } չConnectionsպ ػة٦ٝ׾ⵃ欽
  16. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark 4. Authorization type Query { posts:[Post!]! @aws_auth(cognito_groups: ["Bloggers", "Readers"]) } type Mutation { addPost(id:ID!, title:String!):Post! @aws_auth(cognito_groups: ["Bloggers"]) } Cognito User Group הさ׻ׇג⢪ֲֿהד知⽃ח،ؙإأⵖ䖴ָ〳腉
  17. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark 5. CI / CD New! Multi-environment and team workflow (Beta) Amplifyفٗآؙؑزך醱侧ך橆㞮غحؙؒٝس+ؿٗٝزؒٝس׾盖椚 ׅ׷ֿהָדֹתׅ npm install -g @aws-amplify/cli@multienv
  18. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark 5. CI / CD New! Multi-envi ה Amplify Console ׾穈׫さ׻ׇ׷ Amplify CLIك٦ة晛דفٗؽآّصׁؚٝ׸׋غحؙؒٝس׾䭯׏גְ ׷㜥さծAmplify Consoleכـٓٝث׀החⴽղךغحؙؒٝس׾㾜Ꟛ׃תׅկ GitFlow זוךٙ٦ؙؿٗ٦׾ ⵃ欽׃׋ Pipeline ׾ꬊ䌢ח知⽃ח圓眠ׅ׷ֿ הָדֹ׷
  19. © 2018, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark תה׭ 1. غ٦آّٝ盖椚 • Versionless API ׾䱿㤺 2. Nullability • Typeך嚊䙀׾ֲתֻ⢪׏גծؒٓ٦Ⳣ椚װؿٗٝزךⳢ椚׾知殛⻉ 3. ل٦آط٦ءّٝ • Connection Pattern ׾⢪׏גل٦آؚٝ׾㹋倵 4. Auth • @aws_auth ׾⢪׏גءٝفٕח،ؙإأⵖ䖴 5. CI / CD • Amplify ׾⢪׏ג CI /CD 橆㞮知⽃ח㹋植