Slide 1

Slide 1 text

id:mangano-ito / גࣜձࣾ͸ͯͳ 5 ೥ʹΘͨΔ “ Perl ͷ ” REST API Λ “ Perl Ͱ ” GraphQL API Խ͠࡞Γ௚͢

Slide 2

Slide 2 text

ࢲ ୡ ʹ͍ͭͯ

Slide 3

Slide 3 text

ࢲʹ͍ͭͯ id:mangano-ito גࣜձࣾ͸ͯͳ(ϚϯΨνʔϜ ΞϓϦέʔγϣϯΤϯδχΞ 8FC

Slide 4

Slide 4 text

גࣜձࣾ͸ͯͳ(ϚϯΨνʔϜ ΞϓϦέʔγϣϯΤϯδχΞ 8FC ˣ ϚϯΨΞϓϦνʔϜΤϯδχΞ "OESPJE ࢲʹ͍ͭͯ id:mangano-ito

Slide 5

Slide 5 text

ࢲୡͷϓϩμΫτʹ͍ͭͯ

Slide 6

Slide 6 text

GigaViewer ࣾɾαʔϏεʹಋೖ͞Ε͍ͯΔ 8FCϚϯΨ޲͚Ϗϡʔϫʔ 2017 ʙ

Slide 7

Slide 7 text

৽ͨʹϚϯΨΞϓϦʹରԠͨ͠ϏϡʔϫͰ͋Δ ʮ(JHB7JFXFSGPS"QQTʯΛఏڙ 2021 ʙ GigaViewer for Apps +5 years https://hatenacorp.jp/press/release/entry/2021/11/04/153000

Slide 8

Slide 8 text

͍··Ͱͷࢲୡ

Slide 9

Slide 9 text

͍··Ͱͷ API ։ൃ 3&45"1* "1*ͷυΩϡϝϯςʔγϣϯ όϦσʔγϣϯ

Slide 10

Slide 10 text

hitode909 / APISchem a https://github.com/hitode909/APISchema Made with/for Perl ♥ ࢖ΘΕ͍ͯͨ΋ͷ

Slide 11

Slide 11 text

l"1*Λ࡞ΔͳΒ εΩʔϚϑΝʔετʹ͍ͨ͠ΑͶz

Slide 12

Slide 12 text

👍

Slide 13

Slide 13 text

lҰํɼ ͍··Ͱͷ3&45"1*։ൃͰ͸ ͜͏͍͏ࠔΓ͝ͱ͕͋ͬͨΑͶz

Slide 14

Slide 14 text

ΤϯυϙΠϯτͷϨεϙϯεܗ͕ࣜݻఆ Ұํɺը໘͝ͱʹඞཁͱͳΔϑΟʔϧυ͸ҟͳΔ ‑ ࣅͨΑ͏ͳϦιʔε͕ཚཱ

Slide 15

Slide 15 text

ͦͷ݁Ռ 302 resource s 54 endpoints series series_detail series_detail_of_free_series_campaign series_info_of_free_series_campaign ticket_series Series of `series` resources … serial_series

Slide 16

Slide 16 text

͜ͷը໘͸͜͏ͳΔ ࡞඼λΠτϧ ஶऀ ֓ཁ

Slide 17

Slide 17 text

͜ͷը໘͸͜͏ͳΔ episode_with_series

Slide 18

Slide 18 text

Ұํ ͜ͷը໘Ͱ͸͜͏ͳΔ ࡞඼λΠτϧ ֓ཁ ࠷৽ΤϐιʔυλΠτϧ νέοτ ར༻Մ൱ ͍͍Ͷ਺

Slide 19

Slide 19 text

Ұํ ͜ͷը໘Ͱ͸͜͏ͳΔ serial_series

Slide 20

Slide 20 text

ҧ͍͸… episode_with_series episode author serial_series series

Slide 21

Slide 21 text

ҧ͍͸… episode_with_series episode author serial_series series_supports_ticket series_detail series

Slide 22

Slide 22 text

ҧ͍͸… episode_with_series episode author serial_series series_supports_ticket series_detail series

Slide 23

Slide 23 text

༻్Ͱ෼Խ͍͍ͯͬͯ͠Δ… • series • Ϧετը໘Ͱ͸ܰΊͷσʔλͰ΄͍͠ΑͶʙ • series_detail • ৄࡉը໘Ͱ͸ΑΓଟ͘ͷؔ࿈৘ใ΋͚ͬͭͯ͘΄͍͠ΑͶʙ series series_detail

Slide 24

Slide 24 text

͞Βʹ… • listed_series_info • series + author + ৽ணΤϐιʔυ೔࣌ ͕߹ମͨ͠όʔδϣϯ • listed_series_info_with_ticket • listed_series_info + ticket ৘ใ͕߹ମͨ͠όʔδϣϯ listed_series_info listed_series_info_with_ticket

Slide 25

Slide 25 text

🤯

Slide 26

Slide 26 text

ॊೈੑ දࣔ݅਺΍ूܭ৚݅ͳͲ͕͢΂ͯ αʔόʔαΠυʹ࣮૷͞Ε͍ͯΔ ΞϓϦͷ։ൃલʹαʔόʔαΠυͰ ઌߦͨ͠։ൃͱϦϦʔε͕ඞཁ

Slide 27

Slide 27 text

͋Δ͍͸ϫʔΫϑϩʔ αʔόʔαΠυͰͷඇޓ׵ͳมߋ͸ ڧ੍Ξοϓσʔτ͕ඞཁʹͳΓ͏ΔͷͰ ͳΔ΂͘ͳΒආ͚͍ͨʜʜ

Slide 28

Slide 28 text

͋Δ͍͸ϫʔΫϑϩʔ ഁյతͳมߋΛ๷͙ͨΊʹ ৽ͨͳόʔδϣϯͱͯ͠ Ϧιʔε͕஀ੜͨ͠Γ͢Δ /api/v1/rankings /api/v2/rankings

Slide 29

Slide 29 text

l(SBQI2-Ͱ͸Ͳ͏ͳͷ͔z

Slide 30

Slide 30 text

GraphQL ͷҰൠతͳϝϦοτ 👉ɹؔ࿈͢ΔσʔλΛάϥϑͱͯ͠औಘͰ͖Δ 👍ɹΫϥΠΞϯτଆ͕ඞཁͳ΋ͷ͚ͩ ɹɹॊೈʹऔಘՄೳ 👍ɹαʔόʔଆ͸୯ମͷϦιʔεͱ ɹɹͦͷؔ܎Λهड़͠࠶ར༻Մೳ Ϧιʔεͷരൃ มߋʹର͢Δॊೈੑ

Slide 31

Slide 31 text

͖ͬ͞ͷը໘͸͜͏ॻ͚Δ

Slide 32

Slide 32 text

͖ͬ͞ͷը໘͸͜͏ॻ͚Δ series.titl e series.author.nam e series.description

Slide 33

Slide 33 text

ผͷը໘Ͱʴα͚ͨ͠Ε͹…

Slide 34

Slide 34 text

ผͷը໘Ͱʴα͚ͨ͠Ε͹… ࡞඼λΠτϧ series.description series.latestEpisode.title serie s .supportsTicket series.likeCount

Slide 35

Slide 35 text

series.titl e series.author.nam e series.description

Slide 36

Slide 36 text

ผͷը໘Ͱ-α͚ͨ͠Ε͹… series.titl e series.author.nam e series.description

Slide 37

Slide 37 text

ॊೈੑόπάϯʂ

Slide 38

Slide 38 text

։ൃޮ཰ (SBQIJ2-ศརͳ(SBQI2-ΫϥΠΞϯτ

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

ΧελϚΠζͨ͠Γ΋… https://developer.hatenastaff.com/entry/2021/05/14/093000

Slide 41

Slide 41 text

3&45ˠ(SBQI2- ͯ͠Έͨ͋͘Γ·ͤΜ͔

Slide 42

Slide 42 text

l1FSMͰͰ͖Δͷ͔ʁz

Slide 43

Slide 43 text

👍΋ͪΖΜͰ͖Δ ࣾ಺Ͱ΋࠾༻࣮੷͋Γ ฐࣾͰ͸1FSMͳΒ͜ΕҰ୒ ͱ͍͏ҹ৅

Slide 44

Slide 44 text

lͳʹΛ͢Ε͹Α͍ͷ͔z

Slide 45

Slide 45 text

ઌʹεΩʔϚΛॻ͘

Slide 46

Slide 46 text

ͨͱ͑͹ series ͸͜͏ॻ͚Δ

Slide 47

Slide 47 text

series ΁ͷΫΤϦ͸͜Ε͚ͩ

Slide 48

Slide 48 text

ղܾͷγεςϜ

Slide 49

Slide 49 text

ରԠ͢Δ࣮૷Λॻ͍͍ͯ͘ Resolver

Slide 50

Slide 50 text

ରԠ͢Δ࣮૷Λॻ͘

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

͜͏ͯ͠εΩʔϚϑΝʔετͰ ఆٛˠ࣮૷Λ͍ͯ͘͠

Slide 53

Slide 53 text

جຊ εΩʔϚͱ࣮૷ͷͭͳ͗͜Έ

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

εΩʔϚఆٛΛجʹ Resolver ࣮૷΁ { } Giga::GraphQL::Resolver::Query::Series Giga::GraphQL::Resolver::Series Giga::GraphQL::Resolver::Author GraphQL Schema

Slide 57

Slide 57 text

ൃల গ͠ؤுΓ͸ඞཁʹͳΔ͚ΕͲʜ

Slide 58

Slide 58 text

Τϥʔͷදݱ ͍··ͰΤϥʔΛฦ͍ͯͨ͠෦෼͸Ͳ͏͢Δͷ͔ʁ

Slide 59

Slide 59 text

GraphQL ͷΤϥʔදݱ

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

ΤϥʔϋϯυϥʔΛಋೖ ErrorHandler { } GraphQL::Error Error Report Raised Error Object Error Response { } Query ΤϥʔΛू໿ 🧨

Slide 63

Slide 63 text

Ͱ͖͕͋Δ

Slide 64

Slide 64 text

N+1 ໰୊

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

DataLoader Λಋೖ͢Δ

Slide 67

Slide 67 text

ϖʔδωʔγϣϯ Relay GraphQL Cursor Connections Specificatio n https://relay.dev/graphql/connections.htm

Slide 68

Slide 68 text

ΞμϓλʔΛಋೖ͢Δ Connection Repository Offset = 2 0 Limit = 10 First = 1 0 After = %ABC$ { }

Slide 69

Slide 69 text

ύϑΥʔϚϯε΁ͷऔΓ૊Έ ط஌ͷΫΤϦͷΩϟογϡΛࣄલ࡞੒͠΢ΥʔϜΞοϓ͢Δ ఆظతʹ ΩϟογϡΛ ͭ͘Δ ࣄલʹΫΤϦΛ ετοΫ͓ͯ͘͠ ΞΫηε࣌ʹ͸ Ωϟογϡ͕ ͋ͨͨ·ͬͯΔ

Slide 70

Slide 70 text

ܗ͕Ͱ͖ͨʂ

Slide 71

Slide 71 text

͋ͱ͸ίʔυΛॻ͚ͩ͘ʁ

Slide 72

Slide 72 text

ϑϩϯτΤϯυͰͷ࢖ΘΕํʹΑͬͯ ٻΊΒΕΔεΩʔϚ͕ܾ·Δ "1*։ൃଆ͚ͩͰ͸ܾΊΒΕΔΘ͚Ͱ͸ͳ͍ 👱👱👨🦱👨🦰

Slide 73

Slide 73 text

App νʔϜͱ࿈ܞͨ͠ҙࢥܾఆΛ͍ͨ͠ l྆νʔϜͰ߹ҙΛऔΓͳ͕ΒɹεΩʔϚΛܾΊ͍͖͍ͯͨz ͱ͍͏ͷ͕ 3&45࣌୅͔Βड͚ܧ͕ΕΔߟ͔͑ͨ 👱🤝👱🤝👨🦱🤝👨🦰

Slide 74

Slide 74 text

εΩʔϚϑΝʔετ™

Slide 75

Slide 75 text

ͨͩ…೉͍͠෦෼͕͋Δ εΩʔϚΛߟ͑Δ͜ͱ͕·ͣ೉͍͠ εΩʔϚϑΝʔετΛ࣮ݱ͢Δ೉͠͞ ϫʔΫϑϩʔతͳ೉͠͞΋͋Δ

Slide 76

Slide 76 text

ٕज़͚ͩͰ͸ͳ͍ εΩʔϚϑΝʔετ

Slide 77

Slide 77 text

νʔϜӽڥͨ͠औΓ૊Έ΋ඞཁ

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

զʑͷऔΓ૊Έϧʔϓ ΍Γ͍ܾͨΊ͍ͨ΋ͷ͝ͱ͕͋Δ ͖ͨͨ୆Λߟ͑Δ ձͰಉظతʹ૬ஊ ܾఆ͸ه࿥Λ࢒͢ ࣮૷͢Δ

Slide 80

Slide 80 text

1. ࣮ݱ͍ͨ͠ػೳ͕͋Δ ʮ͜ͷϞσϧΛͲ͏͍͏εΩʔϚͰఆٛ͠Α͏ʯ͸͜Ε

Slide 81

Slide 81 text

2. ͖ͨͨ୆Λߟ͑Δ w ͜͜Ͱ۩ମతͳεΩʔϚҊΛఏࣔͨ͠Γ͢Δ w দ஛കγεςϜͰෳ਺ҊΛఏࣔ͠ɼQSPTDPOTͰٞ࿦ͨ͠Γ

Slide 82

Slide 82 text

3. ձͰಉظతʹ૬ஊ w ຖ೔ΞϓϦνʔϜͷனձʹಥܸ͢Δ w ͦ͜ʹʮ"1*૬ஊίʔφʔʯΛઃ͚ͯ΋Β͍ɼͦ͜Ͱձ࿩͢Δ w ि࣍(JHB(SBQI2-ձ w ͜͜Ͱ͸ΑΓ(SBQI2-"1*ʹಛԽ͍ͯ͠Δ w ೖΓ૊Μͩ࿩Λͨ͠Γ͢Δ

Slide 83

Slide 83 text

4. େ͖͍ܾఆ͸ه࿥Λ࢒͢ w ҙݟ͕͍Ζ͍Ζ͋Δͱ͖΍ࠓޙʹؔΘΔେ͖ͳܾఆ w ૬ஊͷܦҢΛࢀরͰ͖ΔΑ͏ʹ͢Δ w େ͖͘ͳ͍ͱ͖͸୯ʹٞࣄ࿥ʹॻ͚ͩ͘ϓϩμΫτͷه࿥ʹ࢒ͨ͠Γ

Slide 84

Slide 84 text

༷ʑͳܾఆ͕ߦΘΕΔ OVMMBCMF͔OPOOVMM͔ *%Ͳ͏͢Δ͔ ͳΜͰ΋/PEFʹ͸͠ͳ͍ ෳ਺ͷࣅͨܕΛΠϯλʔ ϑΣΠεʹͰ͖ͳ͍͔ ΤϥʔϋϯυϦϯά ৽ͨͳܕͷఆٛ

Slide 85

Slide 85 text

͜͏ͯ͠ "1*͕׬੒

Slide 86

Slide 86 text

ΞϓϦ͕Ͱ͖͕͋Δ (JHB7JFXFSGPS"QQT͕Ͱ͖͕͋Δ

Slide 87

Slide 87 text

͞Βʹ Web Ͱ΋׆༻ αʔόʔαΠυϑϩϯτΤϯυʹͱͬͯ΋׆༻͠΍͍͢ɽ ॊೈʹσʔλΛऔͬͯ͜ΕΔɽ ࠓޙΑΓ׆༻͕ਐΜͰ͍͘༧ఆɽ

Slide 88

Slide 88 text

·ͱΊ 1FSMͰ(SBQI2-"1*Λ࡞Δͷ͸ ࣮૷Λ௥Ճͯ͠ શવͰ͖Δʂ 3&45"1*Ͱͷ։ൃޮ཰ͷ՝୊͸(SBQI2-ʹΑΓվળ͞Εͨʂ αʔόʔɾΫϥΠΞϯταΠυؒͷ࿈ܞ͕։ൃʹ͓͍ͯ؊ཁʂ

Slide 89

Slide 89 text

͋Γ͕ͱ͏͍͟͝·ͨ͠