Laravel+GraphQL 良かったこと 困ったこと 悲しかったこと

Laravel+GraphQL 良かったこと 困ったこと 悲しかったこと

39e7d3ad2417a5fd26d816a51c99e7ce?s=128

ゆうきゃん

May 22, 2019
Tweet

Transcript

  1. Laravel+GraphQL ྑ͔ͬͨ͜ͱ ࠔͬͨ͜ͱ ൵͔ͬͨ͜͠ͱ 2019.05.22 Laravel/Vue.jsษڧձ#9 @ucan_lab (Ώ͏͖ΌΜ)

  2. ࣗݾ঺հ • Name: Ώ͏͖ΌΜ(@ucan_lab) • Company: גࣜձࣾROLO • Skill: PHPer(5೥)/Laravel/GraphQL/Docker(ษڧத)

    • Favorite: λϐΦΧ/εϚϒϥSP • Twitter: https://twitter.com/ucan_lab • Qiita: https://qiita.com/ucan-lab • Laravelͷ։ൃ؀ڥΛDockerΛ࢖ͬͯߏங͢Δ • Laravel PHP InsightsΛ࢖ͬͯίʔυ඼࣭Λ෼ੳ͢Δ
  3. GraphQL஌ͬͯΔਓ!

  4. GraphQL࢖ͬͯΔਓ

  5. ࠓ೔ͷ͓࿩

  6. લஔ͖ • Vueͷ࿩͸͋Γ·ͤΜ • αʔόʔαΠυଆͷࢹ఺ͷ࿩ʹͳΓ·͢

  7. ࠓ೔ͷ͓࿩ • ൵͔ͬͨ͜͠ͱ • GraphQLͷ֓ཁ • LaravelͱGraphQL • GraphQLͷ༻ޠʹ͍ͭͯ •

    ྑ͔ͬͨ͜ͱ • ࠔͬͨ͜ͱ • ·ͱΊ
  8. ൵͔ͬͨ͜͠ͱ

  9. GraphQLͷϥΠϒϥϦ • folkloreinc/laravel-graphql (1788 star) • nuwave/lighthouse (927 star) •

    rebing/graphql-laravel (661 star)
  10. 2018/9 ಋೖ࣌ͷ͓࿩ • ελʔ਺΍ίϛοτ͕׆ൃͳͷ͸ɺ lighthouseϥΠϒϥϦͰ͕͢ಋೖ౰࣌͸200ε λʔ΄Ͳ͔͠ͳ͘ɺlaravel-graphqlΛબ୒ • ΍ͬͺαϙʔτ͞Εͳ͘ͳͬͨΒා͍ • ελʔ਺ଟ͍ͷ͕Ұ൪҆ఆͩΑͶ

  11. None
  12. αϙʔτ͞Εͳ͘ͳͬͨΒ ා͍

  13. օ͞Μ͸ nuwave/lighthouse Λ࢖͍ͬͯͩ͘͞

  14. GraphQLͷ֓ཁ

  15. GraphQLͷ֓ཁ • Facebook͕։ൃ • 2015೥ʹొ৔ • ڧྗͳܕγεςϜ • WebAPIʹ໰͍߹ΘͤΔͨΊͷΫΤϦݴޠ
 (SQLͷΑ͏ͳΠϝʔδ)

  16. REST

  17. GraphQL

  18. LaravelͱGraphQL

  19. LaravelΞʔΩςΫνϟ Client I/O Application Domain Data Source 3%# ,74 Route

    Request Middleware Controller Model Repository Resource UseCase Response "1*
  20. ֤ϨΠϠʔͷ໾ׂ Input Application Domain Output Route Request Middleware Controller Model

    Repository Resource UseCase Response 63-ͱίϯτϩʔϥͷϚοϐϯά ύϥϝʔλͷܗࣜόϦσʔγϣϯɺॏෳνΣοΫ౳ͷ%#ΞΫηε͸͠ͳ͍ ೝՄɺ$43'νΣοΫɺ$034ઃఆɺڞ௨ϩΪϯάॲཧɺڞ௨ྫ֎ॲཧ ϦΫΤετड෇ɺϢʔεέʔεݺग़ɺϨεϙϯεฦ٫ɺϩδοΫ͸هࡌ͠ͳ͍ ॏෳνΣοΫ౳ͷόϦσʔγϣϯɺϏδωεϩδοΫ࣮૷ɺτϥϯβΫγϣϯॲཧ ෳࡶͳ42-ͷ૊ΈཱͯɺඞཁʹԠͯ͡ΩϟογϯάॲཧɺϞσϧͷݺͼग़͠ &MPRVFOU03.ɺίʔυϚελ &OVN "1*ͷϦιʔε &MPRVFOUͱ+40/ϨεϙϯεͱͷτϥϯεϨʔγϣϯ૚ "1*ͷ+40/ϨεϙϯεΛฦ٫
  21. LaravelʴGraphQLͷϨΠϠʔͷ໾ׂ Input Application Domain Output Route Request Middleware Controller Model

    Repository Resource UseCase Response 2VFSZ .VUBUJPOͷ໊લ͕ϧʔςΟϯάͱஔ͖׵ΘΔ 2VFSZ .VUBUJPOͷҾ਺Ͱ5ZQFࢦఆɺ ϛυϧ΢ΣΞ͸ͦͷ··ར༻ ࢖༻͠ͳ͍ɻ2VFSZ .VUBUJPOͷSFTPMWFS͔ΒϢʔεέʔεΛݺग़ ͜͜ʹϏδωεϩδοΫΛ࣮૷͢Δ ϦϙδτϦ͸ͦͷ··࢖༻ Ϟσϧ͸ͦͷ··࢖༻ ࢖༻͠ͳ͍ɻΫϥΠΞϯτଆͰ5ZQF͔ΒඞཁͳϑΟʔϧυΛऔಘ "1*ͷϨεϙϯεΛฦ٫
  22. LaravelΞʔΩςΫνϟ Client I/O Application Domain Data Source 3%# ,74 Route

    Request Middleware Controller Model Repository Resource UseCase Response "1* (SBQI2-
  23. GraphQLͷ༻ޠ

  24. λΠϓ(Type) • GraphQLಠࣗͷܕ • λΠϓ͸ͲΜͳϑΟʔϧυΛ͔࣋ͭΛఆٛ • ΫΤϦʔɺϛϡʔςʔγϣϯͷҾ਺΍ฦΓ஋ • ϑΟʔϧυ໊͕EloquentͷϓϩύςΟ΍Ϧ Ϩʔγϣϯ໊ͱҰகͯ͠Ε͹͍͍ײ͡ʹऔಘ

  25. ΫΤϦʔ(Query) • σʔλͷಡΈࠐΈͷΈ • RESTͰ͍͏GET • ཉ͍͠ϑΟʔϧυΛ࢖͏ଆͰ೚ҙʹࢦఆ • ఆٛͨ͠ΫΤϦͱಉ͡ܗͰjson͕ฦͬͯ͘Δ

  26. ΫΤϦʔྫ1

  27. ΫΤϦʔྫ2

  28. ΫΤϦʔྫ3

  29. ϛϡʔςʔγϣϯ • σʔλͷॻ͖ࠐΈ • RESTͰ͍͏POST, PUT, DELETE౳ • ฦΓ஋ʹGraphQLಠࣗͷܕΛઃఆͰ͖Δ

  30. ϛϡʔςʔγϣϯྫ1

  31. ྑ͔ͬͨ͜ͱ

  32. ྑ͔ͬͨ͜ͱ • APIυΩϡϝϯτ͕ࣗಈੜ੒͞ΕΔ • ࣮ߦ؀ڥ(GraphQL Playground)͕༏ल • ϧʔςΟϯάઃܭ͕ෆཁ • Ϟσϧͱͷ਌࿨ੑ(ϓϩύςΟɺϦϨʔγϣϯ)

    • Laravel dump-server ͱҰॹʹ࢖͏ͱ։ൃָ͕ • ॳΊͯͷਓ΋εϜʔζʹೖΕͨ • ଞͷϓϩδΣΫτͰ΋࢖͏ଆ͸ಉ͡ίʔυ͕࢖͑Δ
  33. GraphQL࣮ߦ؀ڥ • GraphiQL • PlayGround • Altair • GraphQL IDE

  34. GraphQL PlayGround

  35. ࠔͬͨ͜ͱ

  36. ࠔͬͨ͜ͱ • ৘ใ͕গͳ͘ɺϥΠϒϥϦίʔυΛ௥͏೔ʑ • ϥΠϒϥϦͷσόοά͕ਏ͍ • ΫΤϦʔɺϛϡʔςʔγϣϯͷڞ༗ͮ͠Β͍
 (Postmanͷ༷ʹΠϯϙʔτɺΤΫεϙʔτ͍ͨ͠) • KeynoteͰ࡞ͬͨࢿྉͷΞοϓϩʔυํ๏

  37. ·ͱΊ

  38. ·ͱΊ • ϥΠϒϥϦ͸ lighthouse Ұ୒ • PlayGround͕ศར͚ͩͲڞ༗ػೳ͕ཉ͍͠ • APIυΩϡϝϯτͷੜ੒͕ศར •

    ΫϥΠΞϯτͱͷ΍ΓऔΓ͕εϜʔζ
  39. ׬