Slide 1

Slide 1 text

HasuraΛ׆༻͢ΔͨΊͷTipsू 2022/08/30 ։ൃ2෦ ૣ੉࿨ً

Slide 2

Slide 2 text

ࣗݾ঺հ ● ૣ੉࿨ً ● ग़඼؅ཧSaa S ○ ϓϩδΣΫτϦʔμʔ ○ ϑϧελοΫΤϯδχΞ ● ࠷ۙͷϚΠϒʔϜ ○ ݸਓ։ൃ࠶։͠·ͨ͠ ■ Cloud Run(gqlgen) + Firestore(Datastore mode ) ■ Next.js + Rela y ○ Ҿͬӽ͠४උத

Slide 3

Slide 3 text

ΞδΣϯμ ● Hasuraͱ͸ ● HasuraΛ׆༻͢ΔͨΊͷTipsू ○ Upsertͷ׆༻ ○ τϥϯβΫγϣϯ ○ ϦϨʔγϣϯΛؚΜͩMutatio n ○ σΟϨΫςΟϒʹΑΔ੍ޚ ● ͓ΘΓʹ

Slide 4

Slide 4 text

ΞδΣϯμ ● Hasuraͱ͸ ● HasuraΛ׆༻͢ΔͨΊͷTipsू ○ Upsertͷ׆༻ ○ τϥϯβΫγϣϯ ○ ϦϨʔγϣϯΛؚΜͩMutatio n ○ σΟϨΫςΟϒʹΑΔ੍ޚ ● ͓ΘΓʹ

Slide 5

Slide 5 text

Hasuraͱ͸ ● DBͷεΩʔϚ͔ΒGraphQLαʔόʔΛੜ੒Ͱ͖ΔΦʔϓϯιʔε ● DB͑͋͞Ε͹αʔόʔཱ͕ͯΒΕΔͷͰ࣮૷ίετ͕֨ஈʹݮΔ

Slide 6

Slide 6 text

ΧελϜϩδοΫʹ͍ͭͯ ● ΧελϜϩδοΫΛ௥Ճ͢Δํ๏ΛHasura͸ఏڙ͍ͯ͠Δ ○ Actio n ○ Remote Schem a ● ҙ֎ͱΧελϜϩδοΫΛ࣮૷͍ͨ͠৔໘͸ଟ͍ ● ࣮ͨͩ͠૷ίετɺϝϯςφϯείετ͕૿Ճ͢Δ

Slide 7

Slide 7 text

HasuraͷػೳΛ׆༻͢Δ͜ͱͰ
 ΧελϜϩδοΫͷ࣮૷ΛݮΒ͢͜ͱ͕Ͱ͖Δ

Slide 8

Slide 8 text

ΞδΣϯμ ● Hasuraͱ͸ ● HasuraΛ׆༻͢ΔͨΊͷTipsू ○ Upsertͷ׆༻ ○ τϥϯβΫγϣϯ ○ ϦϨʔγϣϯΛؚΜͩMutatio n ○ σΟϨΫςΟϒʹΑΔ੍ޚ ● ͓ΘΓʹ

Slide 9

Slide 9 text

Upsertͷ׆༻ on_conflictΛࢦఆ͢Δ͜ͱͰUpsertͰ࣮ߦ

Slide 10

Slide 10 text

Upsert࢖༻࣌ͷ஫ҙ఺ ● σʔλ͕ଘࡏ͢Δ͔Θ͔Βͳ͍৔߹ͷΈ࢖༻͢Δ ○ ϕʔεͷMutation͸InsertͳͷͰશͯͷඞਢύϥϝʔλΛ౉͢ඞཁ͕͋Δ ○ Updateͷ୅༻ͱͯ͠͸࢖͑ͳ͍ ● σʔλ͕ଘࡏ͢Δ͜ͱ͕Θ͔͍ͬͯΔ৔߹͸UpdateΛ࢖༻͢Δ

Slide 11

Slide 11 text

ΞδΣϯμ ● Hasuraͱ͸ ● HasuraΛ׆༻͢ΔͨΊͷTipsू ○ Upsertͷ׆༻ ○ τϥϯβΫγϣϯ ○ ϦϨʔγϣϯΛؚΜͩMutatio n ○ σΟϨΫςΟϒʹΑΔ੍ޚ ● ͓ΘΓʹ

Slide 12

Slide 12 text

τϥϯβΫγϣϯ Hasura͸1ͭͷϦΫΤετʹෳ਺ͷMutationؚ͕·Ε͍ͯΔ৔߹ɺ
 ֤Mutation͸1ͭτϥϯβΫγϣϯͰॱ൪ʹ࣮ߦ͞ΕΔ ͲΕ͔ҰͭͰ΋ࣦഊͨ͠৔߹શͯͷMutation͕ϩʔϧόοΫ͞ΕΔ

Slide 13

Slide 13 text

τϥϯβΫγϣϯͷྫ deletePost͕ࣦഊͯ͠SampleMutationશମ͕ϩʔϧόοΫ͞ΕΔ ϩʔϧόοΫ͞ΕΔͷͰtaggings͸࡟আ͞Ε͍ͯͳ͍

Slide 14

Slide 14 text

ΞδΣϯμ ● Hasuraͱ͸ ● HasuraΛ׆༻͢ΔͨΊͷTipsू ○ Upsertͷ׆༻ ○ τϥϯβΫγϣϯ ○ ϦϨʔγϣϯΛؚΜͩMutatio n ○ σΟϨΫςΟϒʹΑΔ੍ޚ ● ͓ΘΓʹ

Slide 15

Slide 15 text

ϦϨʔγϣϯΛؚΜͩMutation Mutationͷ૊Έཱͯ࣍ୈͰ༷ʑͳϦϨʔγϣϯΛؚΜͩσʔλͷ࡞੒͕Մೳ ● 1: 1 ● 1: N ● N:N

Slide 16

Slide 16 text

1:1ͷϦϨʔγϣϯ profileͱͦΕʹඥͮ͘userΛ࡞੒ userͱͦΕʹඥͮ͘profileΛ࡞੒͠Α͏ͱ͢ΔͱΤϥʔ

Slide 17

Slide 17 text

ΦϒδΣΫτͷ࡞੒ॱং σϑΥϧτͰ͸1:1ͷϦϨʔγϣϯ͸Լهͷॱ൪ͰΦϒδΣΫτ͕࡞੒͞ΕΔ 1. ࢠΦϒδΣΫτΛ࡞੒ͯ͠idΛऔಘ 2. FKΧϥϜʹ 1 Ͱऔಘͨ͠idΛઃఆͯ͠਌ΦϒδΣΫτΛ࡞੒ ※ ϦϨʔγϣϯ࡞੒࣌ͷinsertion_orderͷઃఆͰॱ൪͸มߋՄೳ

Slide 18

Slide 18 text

1:NͷϦϨʔγϣϯ ౤ߘͱͦΕʹඥ͍͍ͮ͘ͶΛ࡞੒

Slide 19

Slide 19 text

ΦϒδΣΫτͷ࡞੒ॱং 1:NͷϦϨʔγϣϯ͸Լهͷॱ൪ͰΦϒδΣΫτ͕࡞੒͞ΕΔ 1. ਌ΦϒδΣΫτΛ࡞੒ͯ͠idΛऔಘ 2. FKΧϥϜʹ 1 Ͱऔಘͨ͠idΛઃఆͯ͠ࢠΦϒδΣΫτΛ࡞੒

Slide 20

Slide 20 text

N:NͷϦϨʔγϣϯ ౤ߘͱͦΕʹඥͮ͘λάΛ࡞੒

Slide 21

Slide 21 text

ߴ౓ͳN:NͷϦϨʔγϣϯ ౤ߘͱͦΕʹඥͮ͘λάΛ࡞੒ɺλάͷ࡞੒͸Upsert λά͕͢Ͱʹଘࡏ͢Δ৔߹͸ͦͷλά ͱඥ෇͚ɺλά͕ଘࡏ͠ͳ͍৔߹͸λ άΛ࡞੒ͯ͠ඥ෇͚ͱ͍ͬͨෳࡶͳ Mutation΋࣮૷Մೳ

Slide 22

Slide 22 text

ΞδΣϯμ ● Hasuraͱ͸ ● HasuraΛ׆༻͢ΔͨΊͷTipsू ○ Upsertͷ׆༻ ○ τϥϯβΫγϣϯ ○ ϦϨʔγϣϯΛؚΜͩMutatio n ○ σΟϨΫςΟϒʹΑΔ੍ޚ ● ͓ΘΓʹ

Slide 23

Slide 23 text

σΟϨΫςΟϒʹΑΔ੍ޚ Hasura͸ඪ४σΟϨΫςΟϒ͕ར༻Մೳ σΟϨΫςΟϒΛ׆༻͢Δ͜ͱͰQuery, Mutationͷදݱͷ෯͕޿͕Δ

Slide 24

Slide 24 text

σΟϨΫςΟϒʹΑΔ੍ޚ @includeͰऔಘ͢ΔϑΟʔϧυΛ੍ޚ @skipͰ࣮ߦ͢ΔMutationΛ੍ޚ

Slide 25

Slide 25 text

σΟϨΫςΟϒʹΑΔ੍ޚ ؔ࿈ͷͳ͍MutationͰ͋Ε͹ϦΫΤετͷ෼ׂͰରԠՄೳ ಉ͡τϥϯβΫγϣϯ಺ͰMutationͷ࣮ߦΛ੍ޚ͍ͨ͠৔߹͸
 σΟϨΫςΟϒͰͷ੍ޚ͕༗ޮ

Slide 26

Slide 26 text

͓ΘΓʹ ● HasuraΛ׆༻͢Δ͜ͱͰόοΫΤϯυͷ࣮૷޻਺ΛݮΒ͢͜ͱ͕Ͱ͖Δ ● ଞʹ΋Hasuraͷػೳ͚ͩͰ࣮ݱͰ͖Δ͜ͱ͸ੵۃతʹ׆༻͢Δͷ͕
 ྑ͍ͱࢥ͍·͢ʂ