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

GraphQLの誤解/rethinking-graphql

 GraphQLの誤解/rethinking-graphql

GraphQL実践ノウハウ
https://speakerdeck.com/sonatard/graphql-knowhow

GraphQL実践ノウハウv2
https://speakerdeck.com/sonatard/graphql-knowhow-v2

宣言的UIの状態管理とアーキテクチャSwiftUIとGraphQLによる実践
https://speakerdeck.com/sonatard/swiftui-graphql

sonatard

March 03, 2022
Tweet

More Decks by sonatard

Other Decks in Programming

Transcript

  1. 1
    (SBQI2-ͷޡղ
    5&$)45"/%(SBQI2-
    !TPOBUBSEͦͳଠ

    View full-size slide

  2. Appify Technologies
    CTO
    ͦͳଠ
    @sonatard

    View full-size slide

  3. 3
    "QQJGZ
    w 4IPQJGZͷΞϓϦΛ/P$PEFͰϦϦʔεͰ͖ΔΔαʔϏε
    w J04ɺ"OESPJE
    w J04ɺ"OESPJEɺ8FCɺόοΫΤϯυͰ(SBQI2-Λར༻͍ͯ͠·͢
    w ࠾༻
    w IUUQTBQQJGZJODDPNKPC

    View full-size slide

  4. (SBQI2-ͷޡղ

    View full-size slide

  5. 5
    (SBIQ2-ͷޡղ
    w ޡղ
    w ʮ(SBQI2-͸ɺ3&45ͱൺֱͯ͠%#ͷΫΤϦʔͷ੹຿ΛΫϥΠΞϯτ͕͔࣋ͭΒε
    Ϛʔτ6*ʹͳΔʯ
    %#
    %#
    ΫϥΠΞϯτ͕௚઀%#ͷΫΤϦʔΛ࣮ߦ͢Δͷ͕
    (SBQI2-ʁ
    %#ͷ
    2VFSZͷ੹຿

    View full-size slide

  6. 6
    (SBIQ2-ͷޡղ
    w 3&45ͱͷൺֱ
    %#
    %#
    3&45͸ΫΤϦʔΛ࣮ߦͰ͖ͳ͍͔ΒɺҎԼͷΑ͏ʹ͸ͳΒͳ͍
    %#ͷ
    2VFSZͷ੹຿

    View full-size slide

  7. 7
    (SBIQ2-ͷޡղ
    w (SBQI2-ͱ3&45ʹ͸ͲͷΑ͏ͳҧ͍͕͋Δ͔ΛվΊͯߟ͑ͯΈΔ
    %#
    %#

    View full-size slide

  8. 8
    (SBIQ2-ͷޡղ
    w 3&45"1*
    w VTFS
    w JE
    w OBNFZBNBEB
    w PSEFS@JE
    w PSEFS
    w JE
    w QSPEVDU@JE
    w VTFS@JE
    w QSPEVDU
    w JE
    w /BNFۺ
    query UserOrder {
    user {
    id
    name
    order {
    id
    product {
    id
    name
    }
    }
    }
    }
    w (SBQI2-
    3&45ͱ(SBQI2-ͷҧ͍͸Կ͔ʁ
    type User {
    id: ID!
    name: String!
    order: Order!
    }
    type Order {
    id: ID!
    product: Product!
    }
    type Product {
    id: ID!
    name: String!
    }

    View full-size slide

  9. (SBIQ2-ͷޡղ
    w (SBQI2-͸3&45ͱൺֱͯ͠ଟ͘ͷ৘ใΛऔಘͰ͖Δʁ
    w /PɹεΩʔϚʹهࡌ͞Εͨ৘ใҎ্͸औಘͰ͖ͳ͍
    w 3&45Ͱ΋(SBQI2-Ͱ΋ଟ͘ͷ஋ΛऔಘՄೳͳ"1*ʹ͢Ε͹औ
    ಘͰ͖Δ͠ɺͦ͏Ͱͳ͚Ε͹औಘͰ͖ͳ͍
    w (SBQI2-͸ɺ%#ͷ2VFSZͷ੹຿ΛΫϥΠΞϯτ͕͍࣋ͬͯΔʁ
    w /PεΩʔϚͰެ։͞ΕͨൣғͰ͔͠ΫΤϦʔͰ͖ͳ͍
    w 3&45ͱಉ౳ͷεΩʔϚͰ͋Ε͹ɺͰ͖Δ͜ͱ͸ಉ͡
    w ͭ·Γෳ਺ճ"1*Λ࣮ߦ͢Δ͔ɺ౓2VFSZΛ౤͛Δ͔ͷҧ͍͔͠
    ͳ͍
    type User {
    id: ID!
    name: String!
    order: Order!
    }
    type Order {
    id: ID!
    product: Product!
    }
    type Product {
    id: ID!
    name: String!
    }
    9

    View full-size slide

  10. 10
    (SBIQ2-ͷޡղ
    w "1*ͷ৘ใྔ͕ಉ͡ͳΒ͹ɺ(SBQI2-͸3&45ͷ
    "1*ΛͰϚοϐϯά͚ͨͩ͠ͷ΋ͷ
    w ͦ͜ʹ(SBQIߏ଄ͱ͍͏ಛ௃ʹΑΓɺϦϨʔγϣ
    ϯ͕͋Δ΋ͷΛ౓ͷΫΤϦʔͰऔಘՄೳʹͳͬ
    ͍ͯΔ
    w 3&45ͳΒෳ਺ճ"1*Λ࣮ߦ͢Δ͜ͱͰಉ౳ͷ
    ͜ͱ͕࣮ݱͰ͖Δ
    query UserOrder {
    user {
    id
    name
    order {
    id
    product {
    id
    name
    }
    }
    }
    }
    w 3&45"1*
    w VTFS
    w JE
    w OBNFZBNBEB
    w PSEFS@JE
    w PSEFS
    w JE
    w QSPEVDU@JE
    w VTFS@JE
    w QSPEVDU
    w JE
    w /BNFۺ
    VTFS
    PSEFS
    QSPEVDU
    ରԠ

    View full-size slide

  11. 11
    (SBIQ2-ͷޡղ
    w ΫϥΠΞϯταΠυͷݡ͞͸૿͑ͯͳ͍
    w Ή͠ΖٯͰɺΫϥΠΞϯταΠυ͕͍࣋ͬͯͨ"1*Λ૊ΈཱͯΔ੹຿͕όοΫΤϯυʹҕৡ͞Ε͍ͯΔ
    %#
    %#
    %#ͷ
    2VFSZͷ੹຿
    %#ͷ
    2VFSZͷ੹຿
    "1*Λ
    ૊ΈཱͯΔ੹຿
    "1*Λ
    ૊ΈཱͯΔ੹຿
    VTFS"1*Λ࣮ߦͯ͠ϨεϙϯεͷPSEFS@JEΛऔಘͯ͠ɺ
    PSEFSPSEFS@JE"1*Λ࣮ߦͯ͠ϨεϙϯεͷQSPEVDU@JEͰ
    QSPEVDUQSPEVDU@JE"1*Λ࣮ߦ͢Δ
    query UserOrder {
    user {
    id
    name
    order {
    id
    product {
    id
    name
    }
    }
    }
    }
    2VFSZΛ౤͛Δ
    JEͷVTFSΛ%#͔ΒҾ͍ͯPSEFS@JEΛऔಘͯ͠ɺ
    JEPSEFS@JEͷPSEFSΛ%#͔ΒҾ͍ͯQSPEVDU@JEΛऔಘͯ͠ɺ
    *EQSPEVDU@JEͷQSPEVDUΛ%#͔Βऔಘ͢Δ
    ཉ͍͠৘ใΛૉ௚ʹهड़

    View full-size slide

  12. 12
    (SBIQ2-ͷޡղ
    w 3&45Ͱ΋ΫϥΠΞϯτʹґଘͨ͠"1*Λ༻ҙ͢Δ͜ͱͰɺΫϥΠΞϯταΠυ͔Β͸ಉ౳ͷମݧΛ
    ಘΒΕΔ͕ɺҎԼͷΑ͏ͳ໰୊͕͋Δ
    %#
    %#ͷ
    2VFSZͷ੹຿
    "1*Λ
    ૊ΈཱͯΔ੹຿
    ը໘ઐ༻ͷ"1*Λ࣮ߦ͢Δ
    ΫϥΠΞϯτͷϢʔεέʔεʹԠͨ͡"1*Λ૊ΈཱͯΔίετ͕ߴ͍
    ·ͨΫϥΠΞϯτͷϢʔεέʔεʹԠͯ͡"1*ͷ࣮૷ͷมߋ͕ඞཁʹͳΔ
    (SBQI2-ͳΒϑϨʔϜϫʔΫ͕ղܾͯ͘͠ΕΔ

    View full-size slide

  13. 13
    (SBIQ2-ͷޡղ
    w ޡղ͞Ε΍͍͢ཧ༝
    w )BTVSBͰ%#͔Β(SBQI2-εΩʔϚͱ࣮૷Λࣗಈੜ੒Ͱ͖Δ
    w %#Λͦͷ··ެ։͍ͯ͠Δ͜ͱʹۙ͘ͳΔ
    %#
    %#͔Βࣗಈੜ੒

    View full-size slide

  14. w ޡղ͞Ε΍͍͢ཧ༝
    w ͔͜͠͠Ε͸(SBQI2-ͷ໰୊Ͱ͸ͳ͘ɺ)BTVSBͷ࢓૊ΈͰ͢
    w ·ͨ)BTVSBͰ3&45"1*ΛఏڙՄೳͰ͋ΔͨΊɺ)BTVSBͷྫΛڍ͛ͯεϚʔτ6*ʹͳΔͱݴͬͯ
    ͠·͏ͱɺ3&45΋ಉ͘͡εϚʔτ6*ʹͳͬͯ͠·͏
    w ஫ҙ
    w )BTVSBΛ൱ఆ͍ͯ͠ΔΘ͚Ͱ͸͋Γ·ͤΜ
    w )BTVSBͷྫ͔Β(SBQI2-Λޡղ͢Δ͜ͱͷ໰୊ఏىΛ͍ͯ͠·͢
    w )BTVSB͸దͨ͠ϢʔεέʔεͰ࢖͑͹ૉ੖Β͍͠πʔϧͰ͢
    14
    (SBIQ2-ͷޡղ
    %#
    %#͔Βࣗಈੜ੒

    View full-size slide

  15. 15
    (SBIQ2-ͷޡղ
    w ޡղ·ͱΊ
    w ʮ(SBQI2-͸ɺ3&45ͱൺֱͯ͠%#ͷΫΤϦʔͷ੹຿ΛΫϥΠΞϯτ͕͔࣋ͭΒεϚʔτ6*ʹͳΔʯΘ
    ͚Ͱ͸ͳ͍
    %#
    %#ͷ
    2VFSZͷ੹຿
    "1*Λ
    ૊ΈཱͯΔ੹຿
    query UserOrder {
    user {
    id
    name
    order {
    id
    product {
    id
    name
    }
    }
    }
    }
    Ϣʔεέʔεݻ༗ͷ"1*࣮૷͸ෆཁͰɺ
    ΫϥΠΞϯτ͕ΫΤϦʔΛॻ͘͜ͱͰ
    ରԠՄೳ
    (SBQI2-͕ޮ཰తʹ"1*Λ
    ૊ΈཱͯΔ੹຿Λ୲ͬͯ͘ΕΔ
    (SBQI2-ͷ࢓༷ͱϑϨʔϜϫʔΫΛ
    αʔόͷલ໘ʹڬΉ͜ͱͰޮ཰తʹ
    ࣮૷Ͱ͖Δ

    View full-size slide

  16. (SBQI2-ͷޡղ

    View full-size slide

  17. 17
    (SBIQ2-ͷޡղ
    w ޡղ
    w ʮ(SBQI2-͸ɺυϝΠϯ΍ϏδωεϩδοΫ͕ΫϥΠΞϯτʹ࿙Εग़͢ʯ
    %#
    %#ͷ৘ใΛͦͷ··औಘͯ͠ɺ͋ͱ͸ΫϥΠΞϯτ
    Ͱ͢΂ͯॲཧ͢Δʁ

    View full-size slide

  18. 18
    (SBIQ2-ͷޡղ
    w ޡղͰઆ໌ͨ͠ͱ͓Γ(SBQI2-͸"1*Λ૊ΈཱͯΔ੹຿ΛόοΫΤϯυʹҕৡͨ͠΋ͷͰ͢ɻ
    w ͭ·Γ3&45Ͱߦ͍ͬͯͨॲཧ͸ɺͦͷ··όοΫΤϯυʹଘࡏ͠·͢ɻ
    %#
    %#ͷ
    2VFSZͷ੹຿
    "1*Λ
    ૊ΈཱͯΔ੹຿
    query UserOrder {
    user {
    id
    name
    order {
    id
    product {
    id
    name
    }
    }
    }
    }
    2VFSZΛ౤͛Δ ϏδωεϩδοΫ

    View full-size slide

  19. 19
    (SBIQ2-ͷޡղ
    w 3&45"1*
    w VTFS
    w JE
    w /BNFZBNBEB
    w BHFࡀ
    w JT"EVMUUSVF
    w VTFS
    w JE
    w OBNFUBOBLB
    w BHFࡀ
    w JT"EVMUGBMTF
    w ٯʹ(SBQI2-͸3&45Ҏ্ʹϏδωεϩδοΫΛόοΫΤϯυʹҕৡ͠΍͍͢΋ͷͰ͢ɻ
    w ྫ͑͹ɺVTFS͕੒ਓ͔Ͳ͏͔൑ఆ͢ΔϩδοΫ͕͋Δͱ͠·͢ɻ
    w ͜ͷͱ͖΋͠BHFΛݩʹΫϥΠΞϯταΠυͰϩδοΫΛॻ
    ͍ͯ͠·͏ͱɺϏδωεϩδοΫ͕࿙Εग़ͯ͠͠·͍·͢ɻ
    w ୅ΘΓʹVTFSʹJT"EVMUϑΟʔϧυΛ௥Ճͯ͠ɺϨεϙϯεΛ
    ฦ͢ͱ͖ʹ൑ఆ݁ՌΛؚΊͯฦ͢ͱ͠·͢ɻ
    w ͜ΕͰద੾ʹϏδωεϩδοΫ͸όοΫΤϯυʹҠΓ·ͨ͠
    w ͔͠͠ϑϩϯτΤϯυͷը໘ʹΑͬͯ͸ɺ໊લ͔͠ඞཁͳ͍
    Մೳੑ͕͋Γ·͢ɻ
    w ͦͷ৔߹ɺJT"EVMUͷܭࢉ͸༨ܭͳ$16ϦιʔεΛফඅ͢Δ
    ͜ͱʹͳΓ·͢ɻ
    w JT"EVMUͷܭࢉ͘Β͍ͳΒޡࠩͰ͕͢ɺ͜ͷϩδοΫͷͨΊʹ
    ผͷ.JDSPTFSWJDFT΍֎෦ͷ"1*͔Βऔಘ͢Δ৔߹ʹ͸ɺ໊લ
    Λදࣔ͢Δͨͼʹॏ͍ॲཧ͕૸Δ͜ͱʹͳΓ·͢ɻ

    View full-size slide

  20. 20
    (SBIQ2-ͷޡղ
    query UserName {
    user {
    id
    name
    }
    }
    query UserAge {
    user {
    id
    age
    isAdult
    }
    }
    w ໊લΛදࣔ͢ΔΫΤϦʔ w ೥ྸΛදࣔ͢ΔΫΤϦʔ
    JT"EVMUϑΟʔϧυΛऔಘ͠ͳ͚Ε͹ɺ
    ॏ͍ॲཧ͕࣮ߦ͞Εͳ͍
    JT"EVMU͕ඞཁͳͱ͖͚ͩऔಘ͢Δ
    type User {
    id: ID!
    name: String!
    age: Int!
    isAdult: Boolean!
    }
    w (SBQI2-εΩʔϚ
    ύϑΥʔϚϯεͷӨڹ͕ग़ͳ͍ͨΊ
    6TFSʹJT"EVMUϑΟʔϧυΛ௥Ճ͢Δ͜
    ͱ͕༰қʹͳΔ
    ·ͨJT"EVMUઐ༻ͷϋϯυϥ͕ੜ੒Ͱ͖
    ΔͨΊɺطଘͷ6TFSΛҾ࣮͘૷΁ͷ
    Өڹ΋ͳ͍

    View full-size slide

  21. 21
    (SBIQ2-ͷޡղ
    w ޡղ·ͱΊ
    w ʮ(SBQI2-͸ɺυϝΠϯ΍ϏδωεϩδοΫ͕ΫϥΠΞϯτʹ࿙Εग़͢ʯΘ͚Ͱ͸ͳ͍
    ϏδωεϩδοΫ͸3&45ͱ
    มΘΒͣόοΫΤϯυ͕࣋ͭ
    %#
    %#ͷ
    2VFSZͷ੹຿
    "1*Λ
    ૊ΈཱͯΔ੹຿
    query UserOrder {
    user {
    id
    name
    order {
    id
    product {
    id
    name
    }
    }
    }
    }
    2VFSZΛ౤͛Δ ϏδωεϩδοΫ
    ͦͯ͠(SBQI2-ʹΑΓόοΫΤϯυ͕
    ϩδοΫΛ࣋ͪ΍͍͢࢓૊Έʹ
    ͳ͍ͬͯΔ

    View full-size slide

  22. ΫϥΠΞϯτͷ੹຿ͷݮগ

    View full-size slide

  23. 23
    ΫϥΠΞϯτͷ੹຿ͷݮগ
    w 3&45ͷ৔߹ΫϥΠΞϯταΠυ͸ɺϨεϙϯεΛը໘ʹදࣔ͢Δ7JFX.PEFM΁ม׵͢ΔϩδοΫΛ࣋ͪ·
    ͢ɻ
    %#
    Ϩεϙϯε͔Β7JFX.PEFMʹ
    ม׵͢ΔϩδοΫ
    Ϩεϙϯε

    View full-size slide

  24. 24
    ΫϥΠΞϯτͷ੹຿ͷݮগ
    w (SBQI2-Ͱ͸ɺϢʔεέʔε͝ͱʹॻ͍ͨΫΤϦʔ͔Βੜ੒͞Εͨܕ͸7JFX.PEFMͰ͢ɻ
    w ͦͷܕΛม׵ͨ͠Γ͢Δ͜ͱ͸ͤͣɺͦͷ··7JFXʹදࣔ͢Δ͜ͱ͕େ੾Ͱ͢ɻ
    w ͦ͏͢Δ͜ͱͰɺΫϥΠΞϯταΠυ͔ΒɺߋʹϩδοΫ͕ݮগ͠·͢ɻ
    %#
    Ϩεϙϯε͔Β7JFX.PEFMʹ
    ม׵͢ΔϩδοΫ
    query UserOrder {
    user {
    id
    name
    order {
    id
    product {
    id
    name
    }
    }
    }
    }
    Ϩεϙϯε 7JFX.PEFM

    View full-size slide

  25. ΫϥΠΞϯτͷ੹຿ͷݮগ

    View full-size slide

  26. 26
    ΫϥΠΞϯτͷ੹຿ͷݮগ
    w (SBQI2-Λ࢖͏ͱߋʹ΋͏ͭ੹຿ΛݮΒ͢͜ͱ͕Ͱ͖·͢
    w ΫϥΠΞϯταΠυͰ͸ɺड͚औͬͨϨεϙϯεΛ࠶औಘ͢Δ͜ͱΛආ͚ΔͨΊʹ
    3FEVYͳͲΛ࢖ͬͯϞσϧ͝ͱʹΩϟογϡ͢Δ͜ͱ͕͋Γ·͢ɻ
    %#
    ϨεϙϯεΛ.PEFMʹม׵ͯ͠
    Ωϟογϡ͢ΔϩδοΫ
    Ϩεϙϯε

    View full-size slide

  27. 27
    ΫϥΠΞϯτͷ੹຿ͷݮগ
    w (SBQI2-Ͱ͸ɺ"QPMMP΍3FMBZͳͲͷ(SBQI2-ΫϥΠΞϯτ͕(SBQIߏ଄ͦͷ··ʹΩϟογϡ͢Δ࢓૊Έ
    Λ͍࣋ͬͯ·͢ɻ
    w ͦͷͨΊϨεϙϯε͔Βͷม׵ॲཧ΍ΩϟογϡͷϩδοΫ͸ॻ͘ඞཁ͕͋Γ·ͤΜɻ
    %#
    query UserOrder {
    user {
    id
    name
    order {
    id
    product {
    id
    name
    }
    }
    }
    }
    Ϩεϙϯε 7JFX.PEFM

    7JFX.PEFMΛ
    Ωϟογϡ͢ΔϩδοΫ
    ϨεϙϯεΛΩϟογϡ
    Ωϟογϡώοτ͢Ε͹
    ϦΫΤετΛ౤͛ͳ͍
    (SBQI2-
    ΫϥΠΞϯτ

    View full-size slide

  28. 28
    ΫϥΠΞϯτͷ੹຿ͷݮগ
    w ΫϥΠΞϯτΩϟογϡͷৄࡉ͸ͪ͜ΒΛ͝ཡ͍ͩ͘͞
    w IUUQTTQFBLFSEFDLDPNTPOBUBSETXJGUVJHSBQIRM
    w 3&45Ͱ΋7JFX.PEFMͰ͸ͳ͍Ͱ͕͢ɺϨεϙϯεΛΩϟογϡͯ͘͠ΕΔ3FBDU
    2VFSZͳͲ͕ొ৔͍ͯ͠·͢ɻ

    View full-size slide

  29. 30
    ·ͱΊ
    w ޡղͨ͠(SBQI2-
    w ʮ(SBQI2-͸ɺ3&45ͱൺֱͯ͠%#ͷΫΤϦʔͷ੹຿ΛΫϥΠΞϯτ͕͔࣋ͭΒεϚʔτ6*ʹͳΔʯ
    w ʮ(SBQI2-͸ɺυϝΠϯ΍ϏδωεϩδοΫ͕ΫϥΠΞϯτʹ࿙Εग़͢ʯ
    %#ͷ
    2VFSZͷ੹຿
    "1*Λ
    ૊ΈཱͯΔ੹຿
    ϏδωεϩδοΫ
    %#
    Ϩεϙϯε͔Β
    7JFX.PEFMʹ
    ม׵͢ΔϩδοΫ
    7JFX.PEFMΛ
    Ωϟογϡ͢ΔϩδοΫ
    %#
    ϨεϙϯεΛ.PEFMʹม׵ͯ͠
    Ωϟογϡ͢ΔϩδοΫ
    Ϩεϙϯε
    "1*Λ
    ૊ΈཱͯΔ੹຿
    %#ͷ
    2VFSZͷ੹຿
    ϏδωεϩδοΫ
    .PEFM͔Β
    7JFX.PEFMʹ
    ม׵͢ΔϩδοΫ

    View full-size slide

  30. 31
    ·ͱΊ
    w ద੾ͳ࢖͍ํΛͨ͠(SBQI2-
    w (SBQI2-͸3&45ͱൺֱͯ͠ଟ͘ͷ੹຿Λݞ୅ΘΓͯ͘͠ΕΔ
    w ΫϥΠΞϯταΠυͷίʔυ͸γϯϓϧͰ࠷খݶͷ࣮૷ʹͳΔ
    %#ͷ
    2VFSZͷ੹຿
    "1*Λ
    ૊ΈཱͯΔ੹຿
    ϏδωεϩδοΫ
    7JFX.PEFMΛ
    Ωϟογϡ͢ΔϩδοΫ
    %#
    ΫϥΠΞϯτ͸
    ࠷খݶͷ࣮૷
    7JFX.PEFMΛฦ͢
    ϩδοΫ
    %#
    ϨεϙϯεΛ.PEFMʹม׵ͯ͠
    Ωϟογϡ͢ΔϩδοΫ
    Ϩεϙϯε
    "1*Λ
    ૊ΈཱͯΔ੹຿
    %#ͷ
    2VFSZͷ੹຿
    ϏδωεϩδοΫ
    .PEFM͔Β
    7JFX.PEFMʹ
    ม׵͢ΔϩδοΫ

    View full-size slide

  31. 32
    ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
    4QFBLFS%FDLͷ֓ཁཝʹؔ࿈εϥΠυΛܝࡌ͍ͯ͠·͢

    View full-size slide