Share
Embed
AppSync というか GraphQL 設計 Tips 5選
ktsukago
December 14, 2018
Transcript
19 slides
-
© 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 -
© 2018, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential and Trademark عحءُةؚ #meguro_dev -
© 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 㥨ֹז⹛暟 ֲֺׁ -
© 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 הכ -
© 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דךٔ،ٕة؎ير٦ةך鷏⥋ -
© 2018, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential and Trademark AWS AppSync 嚊銲 Http Query / mutation subscription -
© 2018, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential and Trademark AppSync הכ -
© 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 } } -
© 2018, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential and Trademark ז GraphQL זךַ • REST API ך涪罏ծⵃ欽罏ך铬겗 • API ➬圫ךسًُؗٝز盖椚/ ➬圫ך椚鍑ָ㣐㢌 • API ךسًُؗٝزה㹋鄲ָ׆גג؛ٝؕ • ؙٓ؎،ٝز涪罏ַך♶弫 • ل٦آ邌爙ׅךח⡦⦐ API 〨ַזֽלזזְ • ַׇֻ؎كٝزسٔـٝח⡲גְג؟٦غ٦הך䱸竲כ穠㽷 Request / Responseך䕎ָךֿ -
© 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 -
© 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պ ד嗚稊 -
© 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鼅 -
© 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`.") } -
© 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 鏩〳׃גֶֻ -
© 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պ ػة٦ٝⵃ欽 -
© 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 הさׇג⢪ֲֿהד知⽃ח،ؙإأⵖ䖴ָ〳腉 -
© 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 -
© 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 ꬊ䌢ח知⽃ח圓眠ֿׅ הָדֹ -
© 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 橆㞮知⽃ח㹋植