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

GraphQLのステキポイントと悩ましいポイント

Faf66d1638984fe6276571304120ec64?s=47 maru333
October 09, 2019

 GraphQLのステキポイントと悩ましいポイント

Faf66d1638984fe6276571304120ec64?s=128

maru333

October 09, 2019
Tweet

Transcript

  1. P R E S E N T A T I

    O N B Y @ m a r u 3 3 3 GraphQLͷεςΩϙΠϯτͱ ೰·͍͠ϙΠϯτ
  2. - ৽ଔͰSIerۀ΁ɻΘΓͱ஍ࠈΛΈΔɻ - 2018೥12݄ʹΤϜεϦʔϔɻ - αʔόαΠυKotlinɺGraphQLɻ - αΠίʔ͔Αʂ ← ΠϚίί

    @maru333 ָ͠͞΋͚͋ͬͨͲ
  3. GraphQLͷεςΩϙΠϯτ ✨εςΩ✨

  4. εςΩ̍ GUI͕ॆ࣮͍ͯ͠Δ - query Λͦͷ··ଧͯΔ - ΋ͪΖΜิ׬΋ޮ͘ - σʔλΛ֬ೝͰ͖Δ -

    ݕূͨ͠ΫΤϦΛ ɹͦͷ··࣮ίʔυʹ
  5. εςΩ̎ ResponseCode͕200 OK ΫϥΠΞϯτ A Server ʢओཁʣ B Server ʢαϒʣ

    GraphQL Server ཁٻ ཁٻ OK ཁٻ NG OK Ұ෦੒ޭͷσʔλΛॲཧͰ͖Δ
  6. GraphQLͷ೰·͍͠ϙΠϯτ ೰·͍͠

  7. GraphQL Server ೰·͍̍͠ ઃܭ͕ΫϥΠΞϯτͱີʹ Ϣʔβ৘ใ χϡʔε ͦͷଞ αʔϏε HOMEͷ৘ใ͘Ε HOME

    query HomeInfo() ͦͷଞ αʔϏε HOMEͷ৘ใͩΑ ϙΠϯτ৘ใ Ϣʔβ৘ใ ;Ή;Ή HOMEͷ ৘ใͩͳ
  8. ೰·͍̎͠ nginxͷϩάूܭ͕Ͱ͖ͳ͍ - ϩά͕શͯ200 OK - ࠓ·Ͱͷϩάूܭ͕࢖͑ͳ͍ Stackdriver Trace Ͱ

    ෼ࢄτϨʔγϯά
  9. - extensions ͷத਎͸༷ʑ - ޷͖উखʹ৭ʑೖͬͯ͠·͏ - εΩʔϚͰఆٛͰ͖ͳ͍ - ΧΦε ೰·͍̏͠

    Τϥʔύλʔϯʹղͳ͠ https://www.apollographql.com/docs/apollo-server/data/errors/ - errors object ʹΤϥʔ͕ೖΔ - extensions ʹ޷͖ʹ͍ΕͯͶʂ
  10. ݕ౼̍ HTTP Error Status ʹدͤΔ graphql-java Ͱ͜ΕΛ΍Ζ͏ͱ͢Δͱɺ ͔ͳΓτϦοΩʔͳ࣮૷ʹͳΔˍকདྷʹ౉ͬͯอূͰ͖ͳ͍ ฐࣾCTOஊɿ nginx

    ͱ͔Ͱ HTTP Error ͸Ͳ͏ͤ ൃੜ͢Δ͔Βɺ(ΫϥΠΞϯτͰ ίϯτϩʔϧ͢Δඞཁͷͳ͍΋ͷ͸) GraphQLͷΤϥʔ΋HTTP Error ʹ دͤΔͱ͍͏ͷ͸Ͳ͏͔ʁ → ҰಉɿͳΔ΄Ͳɺ͔֬ʹʂʂʂ
  11. ݕ౼̎ ΤϥʔΫϥεͷఆٛ UserError Unauthorized Error Validation Error query { me

    { … on DataResult {} … on UserError { } } } ͨͩ͠ɺerrorsύλʔϯ΋࢒ΔˍHTTP Error ΋ൃੜ͢ΔͨΊɺ ΤϥʔϋϯυϦϯά͸গ͠ෳࡶʹͳΓͦ͏
  12. ·ͱΊ εςΩϙΠϯτͱ ೰·͍͠ϙΠϯτͷ·ͱΊ - GUIͰ؆୯ʹQueryઃܭ - Ұ෦αʔϏε͕མ͍ͪͯΔঢ়ଶͰ΋ಈ࡞Ͱ͖Δ εςΩ - ઃܭ͕ΫϥΠΞϯτͱີʹ

    - ࠓ·Ͱͷϩάूܭπʔϧ͸࢖͑ͳ͍͔΋ - ΤϥʔͷϕετϓϥΫςΟε͕ແͦ͞͏ ೰·͍͠
  13. ৭ʑ͋Γ·͕͢… GraphQL໘ന͍ʂ օ͞ΜͱҰॹʹ஌ݟΛͨΊ͍ͨʂ GraphQLΛ࢖͍ͬͯΔਓͨͪͷू·Γ https://graphql-users-jp.slack.com/

  14. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ

  15. Vector Icons by Matthew Skiles Presentation template designed by Slidesmash

    Photographs by pexels.com Special thanks to all people who made and share these awesome resources for free: Credits
  16. This presentation uses the following typographies and colors: Colors used

    Free Fonts used: https://www.fontsquirrel.com/fonts/League-Gothic https://www.fontsquirrel.com/fonts/open-sans Presentation Design