ã¿ãªããããã«ã¡ã¯ïŒ
ãã®æè¿ã®èšäºã¯ãç§ã«ãã®åºçç©ãæžã
ããä¿ããŸããïŒæšæ¥èŠãŸããïŒã
Headless / content-first / api-firstãªã©ã®äž»ãªæ©èœãããäžåºŠèª¬æããŠãã ããã ç§ã¯CMSã§ã¯ãããŸãããçŽ æã¯å
å®ããŠãããããããå€ãã®äººããã§ã«ãã®åŸåã«ç²ŸéããŠããŸãã ãããŠãã·ã¹ãã ãäœæããçç±ãšæ¹æ³ãæ¢åã®ã·ã¹ãã ããéžæã§ããªãã£ãçç±ã以åã«ééããä»ã®ã·ã¹ãã ã«ã€ããŠèããŠããããšãããããã¹ãŠã«ã€ããŠã©ã®ãããªèŠéãããããã«ã€ããŠã話ããããšæããŸãã ãã£ã¯ã·ã§ã³ã¯èšå€§ãªéã«ãªããŸããïŒ2幎éã§ãã®è³æã«ã€ããŠïŒãããé¢çœãæçšãªãã®ãæžããŸãã ç«ã®äžã§èª°ãæ°ã«ããŠãã ããã
äžè¬çã«ãç©èªã¯æ¬åœã«é·ããç§ã¯æåã«ããã話ãããšããŸãã ãã®ãšã³ãžã³ãèªåã§äœæããæ¬åœã®çç±ããã£ãšæ確ã«ããããããŸãã¯åã«ããããªããšããªãç§ããã®ããã«ãã£ãŠããã®ããå°äžã§èª¬æããã®ãé£ãããªããŸãã
ããããåå¿è
ã®ããã«ãããã«ãããããããç§ã¯èªåã®ããã«çŸä»£ã®ãããã¬ã¹CMSã®äž»èŠãªéžæåºæºãç°¡åã«æžãçããŸãã
人ã
ãå€ãã®ãããèªãããã«éåãããæçµçã«äœãäŒããããã®ãç解ããŠããªãããã«ãèŠããã«ãç§ã¯ãã¹ãŠã1ãæã«çœ®ããããšæã£ãŠããŸãããèé¢ãšåé¢ã®äž¡æ¹ïŒãããŠãã©ã¡ãã§ããªãïŒãGraphQL-APIããããŠãMake Beautifulããã¿ã³ãªã©ãããŒã¿ããŒã¹ã管çããããšã§ãã ããã¯èŠã€ãããŸããã§ããã ç§èªèº«ããŸã ããããã£ãŠããŸããããå
šäœãšããŠã¯éåžžã«å€ãã®ããšãå€æããŸããããããŠæãéèŠãªããšã¯ãå®éã®ãããžã§ã¯ããè¡ãããšãã§ããããšã§ãã
ãããã£ãŠãç§ã®ã¢ãããŒãã¯ç§åŠçã§æ£åœåããããšã¯ã»ãšãã©èšããŸããã äºå®ãç§ã¯äžè¬çã«èªåã®äœããæžãããšãéåžžã«å€ãã§ãã ããã§ããã°ã©ã ããã®ã奜ãã§ãã ãããŠ2幎åïŒãããŠãã®8幎åïŒã«ç§ã¯MODX CMFã«åº§ã£ãŠããŸããïŒãã®äžã§å€ãã®æŸèæãçºæããŸããïŒã ãããŠ3幎éãããªã倧èŠæš¡ãªãããžã§ã¯ããéå§ããŸãããããã®äžã§MODXã䜿çšã§ããããã«æããŸããã ããããçµå±ã®ãšãããç§ã¯ã§ããŸããã§ãã...äž»ãªçç±ã¯ãæè¡çãªèŠä»¶ã®ãªãã¹ã¿ãŒãã¢ããã§ãããæ¯æ¥ïŒãããŠ1æ¥ã«æ°åïŒå€åããè£è¶³ãããå€ãã®ã¢ã€ãã¢ããã£ãããšã§ãã ãããŠä»ãæ°ããã¢ã€ãã¢ã®äžã§ãæ°ãããšã³ãã£ãã£ãè¿œå ããæ¢åã®ãšã³ãã£ãã£ã®ãã£ãŒã«ããç»é²/å€æŽãããããã®ãšã³ãã£ãã£éã®é¢ä¿ãäœæ/åé€/å€æŽããå¿
èŠããããã³ã«ïŒãããããããŒã¿ããŒã¹æ§é ã®å€æŽã«äŒŽãïŒãããæç¹ã§ãããã®ãšã³ãã£ãã£ãå€æŽããã®ã«æ°æéããããŸããã å®éããããã®å€æŽãã¹ããŒã ã«ç»é²ããå¿
èŠããããšããäºå®ã«å ããŠãããŒã¿ããŒã¹ã®å€æŽïŒã»ãŒæåïŒãAPIã®æŽæ°ãããã°ã©ã ã³ãŒãã®æžãæããªã©ãå¿
èŠã§ããã ãããã£ãŠããã®ãã¹ãŠã®äžã§åç·ãæŽæ°ããå¿
èŠããããŸããã ãã®çµæãç§ã¯æ°ããããã䟿å©ãªãã®ãæ¢ãå¿
èŠããããšå€æããŸããã ãã®ãšããç§ã¯phpããã¯ãšã³ãã ã£ãããšãããäžåºŠæ確ã«ããŸãããã®ãããããŸããŸãªããã³ããšã³ããã«ããŒãå°ãªãããã»ããµãnpmãªã©ãçºèŠãå§ããããšã«é©ããªãã§ãã ããã ãªã© ãããããšã«ãããç§ãã¡ã®ãããžã§ã¯ãã§ã¯åŸã
ã«ãreact + lessãGraphQLã®APIãããã³expressã®ãµãŒããŒã«åç·ãçŸããŸããã
ãããããã¹ãŠãä»ã®ããã«ãã©è²ã§ãããšã¯éããŸããã ããã¯2幎以äžåã§ããããšãæãåºãããŠãã ããã ææ°ã®JS Webã«2幎æªæºããã¢ã¯ã»ã¹ããŠã
ãªãå Žåã¯ã次ã®èšäºãèªãããšããå§ã
ããŸã ãCreateReact
ã¢ã㪠ïŒhabrïŒ
ã䜿çšããNåã®çç± ã ç°¡åã«èšããšãåå¿ã¹ã¯ãªããã®åºçŸã«ãããwebpackã®æ§æãªã©ã«ç
©ããããããšã¯ãããŸããã ããã¯ãã¹ãŠããã¯ã°ã©ãŠã³ãã«å
¥ããŸãã 芪åãªäººã¯ãã§ã«webpackãèšå®ããŠããã®ã§ãã»ãšãã©ã®åå¿ãããžã§ã¯ãã¯ã»ãšãã©åäœããããšãä¿èšŒãããŠãããæçµéçºè
ã¯äŸåé¢ä¿ãããŒããŒãªã©ãèšå®ããã®ã§ã¯ãªããæçµè£œåã®ããã°ã©ãã³ã°ã«çŽæ¥éäžããŠããŸãã ããããããã¯åŸã§ãã ãããŠãã®åã«ãç§ã¯ãã®ãŠã§ãããã¯ãèšå®ããè¿œãã€ãããã«åœŒãšäžç·ã«é£ãã ãã¹ãŠã®æã®æŽæ°ã«åŸãå¿
èŠããããŸããã ãªã© ããããããã¯äœæ¥ã®äžéšã«ããããæ¬è³ªçã«ã¯åç·ã«ãããŸããã ãŸãããµãŒããŒãå¿
èŠã§ãã ãŸããAPIãå¿
èŠã§ãã ãŸããSSRïŒãµãŒããŒåŽã¬ã³ããªã³ã°ïŒãå¿
èŠã§ããç§ãç¥ãéããåå¿ã¹ã¯ãªããã¯ãŸã æäŸããŠããŸããã äžè¬ã«ããã¹ãŠã¯ä»ãããã¯ããã«è€éã§ãããã»ã©å€ãã¯ãããŸããã§ããã ãããŠãã©ããã£ãŠç§ã¯æŸèæãã€ããŸããã...
æ³åããŠã¿ãŠãã ããïŒ
- ããã³ãããã³ãµãŒããŒçšã®ãã€ãã£ãwebpackæ§æã
- SSRã®ç¬èªã®å®è£
ãasyncãreact-serverã§æ£åžžã«åäœããã¹ã¿ã€ã«ãããã«å°çããæ£åžžã«ã€ã³ããã¯ã¹ä»ããããèŠã€ãããªãããŒãžã®ãµãŒããŒã¹ããŒã¿ã¹ãæäŸãããŸãã
- ããŒãªãã¥ãŒã¹ã ããŠãç§ã¯ããã«reduxã奜ãã§ã¯ãããŸããã§ããã ç§ã¯ãã€ãã£ãã®åå¿ãã©ãã¯ã¹ã䜿çšãããšããã¢ã€ãã¢ã奜ãã§ããïŒãã ããèªåã§å°ãæžãçŽããªããã°ãªããŸããã§ãããïŒã
- ããŒã¿ããŒã¹ãèªåå±éããã«ãGraphQLã¹ããŒã ãšãªãŸã«ããæåã§æå®ããŸããïŒAPIãµãŒããŒã¯MODXãµã€ãã®äžéãšããŠäœ¿çšãããŸããïŒã
- react-apollo / apollo-clientãªã©ã¯ãããŸãã ãã¹ãŠã¯ãã«ã¹ã¿ã ãã©ãã¯ã¹ã«åºã¥ããŠããã©ãŠã¶ãŒã§ã®ãã§ããããªããžããªãŒãä»ããèŠæ±ã§åå¥ã«æžã蟌ãŸããŸãã
ãã®çµæããããŸã§ãããã®æåã®ããŒãžã§ã³ã®1ã€ã«ã¯ã500人以äžã®åºåžè
ããããããžã§ã¯ãããããã·ãŒãºã³ïŒå¬ïŒã«ã¯1æ¥ããã1000ã1700人ã®ãŠããŒã¯ãªåŠçãããŸãã 皌åæé2ãæã ããã¯ãäºé²çãªãœãããŠã§ã¢ã®æŽæ°åŸã«ãµãŒããŒãæåã§åèµ·åããããã§ãã ãã®åèµ·ååã«ã¯ã皌åæéã¯ããã«6ãæ以äžã§ããã ããããæãèå³æ·±ãã®ã¯ã¡ã¢ãªæ¶è²»ã§ãã çŸåšãã»ãŒ700ã¡ã¬ãã€ãã®jsããã»ã¹ããããŸãã ã¯ããã¯ããç§ãããã§ããªããšç¬ã£ãŠããŸã:)ãã¡ãããããã¯ãããããããŸãã ãããŠãã®åã«ãç§ã¯ããå°ãäºé²ãããã®ææšãæ¹åããŸããã 以åã¯ãããã»ã¹ããšã«åèš1000M +ããããŸãã...ããã«ãããããããããã¯æ©èœããããªã蚱容ã§ããŸããã ãŸãã11æã«
GoogleãPageSpeed Insightsã¢ã«ãŽãªãºã ãå€æŽããåã¯ããµã€ãã®ããã©ãŒãã³ã¹ã¡ããªãã¯ã¯97/100ã§ããã
蚌æãã®ãããžã§ã¯ããªãã§ããã«éçºãããã·ã¹ãã ã«åºã¥ããããã®ãããžã§ã¯ãã«åºã¥ãäžéçµè«ïŒãããžã§ã¯ãã¯åãæ®ãããŸããïŒïŒ
é·æ- GraphQLã䜿çšããããšã§ãããžã§ã¯ãAPIãããæè»ã«ãªãããµãŒããŒãªã¯ãšã¹ãã®æ°ã倧å¹
ã«åæžãããŸããã
- ãããžã§ã¯ãã¯ãnpmäžã®èšå€§ãªæ°ã®ã³ã³ããŒãã³ãã«ã¢ã¯ã»ã¹ã§ããŸãã
- äŸåé¢ä¿ãgitãªã©ã䜿çšããããšã§ããããžã§ã¯ã管çãããéæã«ãªããŸããã
- çµæãšããŠãã®åç©åããäœãåé€ã§ãããããããªãå ŽåïŒãããŠã1ã€ã®ãµã€ãã§è€æ°ã®ããŒãžã§ã³ã®ãã°ãèŠãããšã¯çãããããŸããïŒãæ§ç¯ãããã¹ã¯ãªãããšã¹ã¿ã€ã«ã¯ãå€ããµã€ãã®äžé£ã®åå¥ã®ã¹ã¯ãªããããã確ãã«æ¥œããã§ãã
- ãµã€ãã¯ããã€ã³ã¿ã©ã¯ãã£ãã«ãªããããŒãžã¯åèµ·åããã«æ©èœããŸãã以åã«è¡šç€ºããããŒãžã«æ»ãããã«ãµãŒããŒãç¹°ãè¿ãåŒã³åºãå¿
èŠã¯ãããŸããã
- ããŒã¿ç·šéã¯ãããŒãžäžã§çŽæ¥å®è¡ãããŸããã衚瀺ãããã®ãšè¡šç€ºãããã®ãç·šéããããšããååã«åºã¥ããåå¥ã®ç®¡çããã«ã¯ãããŸããã
çæïŒäž»ã«éçºè
åãïŒ- ãã¹ãŠãéåžžã«è€éã§ãã æ¬åœã«ã äžéšã®ãµãŒãããŒãã£éçºè
ã®ãããžã§ã¯ããžã®æ¥ç¶ã¯ãåçŽã«éçŸå®çã§ãã ç§ã¯ãããäœãã©ã®ããã«æ©èœããç§ã®è¶³ãã©ãããæé·ããããã»ãšãã©ç解ããŠããªãã£ãã éææ§ã«ã€ããŠèšåãããŠãããã©ââã¹ã®3ããŒãžãèŠããšãéææ§ã¯ã©ããã«ããã¯ãããšãå£ããŠãããã®ãããã«èŠãããšãã§ããŸãïŒã¹ã¯ãªããã¯æ§ç¯ãããŸããïŒããã³ããããšå·®åã«ãã£ãŠããªãã¯ãããåŒã£ããã£ãå ŽæãèŠã€ããããšãã§ããŸãã ãŸããäœãæ°ãããã®ãè¿œå ããããšãã§ãããããæ©èœããå Žåãå°ãªããšããã¯ãããã¹ãŠãããŸãé£ãã ããšãæ確ã«ç解ããŠããŸãã ããããå
šäœçã«ã¯ãŸã å°çã®ãããªå°çã§ãã
- ãã£ãã·ã³ã°ã®é£ããã ãã®åŸãç§ã¯èªåã®ããã«ã¢ããã¯ã©ã€ã¢ã³ããçºèŠããŸããã ãããŠãã®åã«ãç§ãèšã£ãããã«ããã©ãã¯ã¹ããŒã¹ã®ã¹ãã¬ãŒãžãæžããŸããã ãããã®ã¹ãã¬ãŒãžã«ãããããŸããŸãªã³ã³ããŒãã³ãããã¬ã³ããªã³ã°ã«å¿
èŠãªããŒã¿ãååŸã§ããŸããããã¯ã©ã€ã¢ã³ãåŽã®ãã£ãã·ã¥ãµã€ãºã¯éåžžã«å€§ããã£ãïŒãšã³ãã£ãã£ã®åã»ããã«ã¯ç¬èªã®ãªããžããªããããŸããïŒã ãã®çµæããªããžã§ã¯ãã以åã«ãªã¯ãšã¹ãããããã©ããïŒã€ãŸãããããèŠã€ããããã«ãµãŒããŒã«ãªã¯ãšã¹ããã䟡å€ããããã©ããïŒãé¢é£ãããã¹ãŠã®ããŒã¿ãå©çšå¯èœãã©ãããªã©ãæ€èšŒããããšã¯å°é£ã§ããã
- ã¹ããŒããããŒã¿ããŒã¹æ§é ããªãŸã«ãã®åé¡ïŒããŒã¿ãåä¿¡/å€æŽããããã®APIæ©èœïŒã ç§ãèšã£ãããã«ãç§ã¯æåã§åè·¯ãæžãããªãŸã«ããæžããŸããã ãªãŸã«ãã§äœããããã§ããã£ãã·ã¥ãæäŸãããã¹ãããããªã¯ãšã¹ãããã®ä»ã®åŸ®åŠãªåŠçãæäŸããããšããŸããã ãã®ç¬éãç§ã¯æ¬è³ªãšGraphQLããã°ã©ã ã³ãŒãã«æ·±ãå
¥ã蟌ãŸãªããã°ãªããŸããã§ããã å©ç¹ã¯ãGraphQLã®ä»çµã¿ããã®é·æãšçæãããã³ããããããã調çããæ¹æ³ãäžè¬çã«ããç解ããŠããããšã§ãã æ¬ ç¹ã¯ããã¡ãããã¢ããã®ãããªã³ãã³ãã§æžãããã¢ã¡ããã£ããã³ããã¹ãŠ1ã€ã«æžãããšãã§ããªãããšã§ãã ãã®çµæãç§ãã¢ãããçºèŠãããšãããã¡ãããç§ã¯ãããã®ã³ã³ããŒãã³ããéåžžã«åãã§äœ¿ãå§ããŸããïŒããããäž»ã«åé¢ã§ã以äžã«ãã®çç±ã説æããŸãïŒã
äžè¬çã«ãæ代é
ãã®ãã¯ãããžãŒã䜿çšãããã®ãããžã§ã¯ãã¯ãå人çã«ã¯100ïŒ
ã®ãã®ã§ãããããããè¯ãææãŸã§ãããæŸæ£ããäœè£ããããŸãã ããããããã«é²ãã§ãã©ãããã©ãŒã ãéçºããå¿
èŠããã£ãä»ã®ãããžã§ã¯ãããããŸãã ãããŠæ°åããã¹ãŠããŒãããæžãçŽããªããã°ãªããŸããã§ããã ããã«ãééããåã
ã®ã¿ã¹ã¯ãšããã®çµæãšããŠéçºããã³é©çšãããœãªã¥ãŒã·ã§ã³ã«ã€ããŠè©³ãã説æããŸãã
ã¹ããŒããã¡ãŒã¹ãã æåã«åè·¯ã次ã«ä»ã®ãã¹ãŠãµã€ãïŒWebã€ã³ã¿ãŒãã§ã€ã¹ãã·ã³ã¯ã©ã€ã¢ã³ããªã©ïŒã¯ãã¹ãŠæ
å ±ã®è¡šç€ºã§ãïŒèš±å¯ãããŠããå Žåã¯æ
å ±ç®¡çãããã³èš±å¯ãããŠããå Žåã¯æ©èœãèš±å¯ãããŸãïŒã ããããæåã«ããã¹ãŠåããããŒã¿ããŒã¹ïŒããŒãã«ãåãªã©ïŒã éäžã§ããŒã¿ããŒã¹ãæäœããããã®ããã€ãã®ç°ãªãã¢ãããŒãã«ééããã®ã§ãç§ã¯ã¹ããŒããã¡ãŒã¹ãã®ã¢ãããŒããæã奜ãã§ããã ã€ãŸãããšã³ãã£ãã£ãšããŒã¿åã®ã¹ããŒããïŒæåãŸãã¯ã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠïŒèšè¿°ããã¹ããŒããå±éããèšè¿°ãããå€æŽãããŒã¿ããŒã¹ã«ããã«é©çšããŸãïŒããŒãã«/åãäœæ/åé€ããããããã®éã®é¢ä¿ãïŒã å®è£
ã«å¿ããŠããã®ããŒã¿ã管çããããã«å¿
èŠãªãã¹ãŠã®ãªãŸã«ããŒé¢æ°ãçæããŸãã äœããããã®æ¹åã§ãç§ã¯
prisma.ioãããžã§ã¯ãã奜ãã§ããã
ããªãã®èš±å¯ãåŸãŠãç§ã¯ããã«ã€ããŠãããªãºã ã«ã€ããŠã®èšäºãèŠãããšããªãã®ã§ãç§ã¯åœŒãã«å°ã泚æãåŒããŸãããããžã§ã¯ãã¯æ¬åœã«éåžžã«èå³æ·±ãããã§ãããããŠã圌ããªãã§ã¯ãç§ããããªã«åã°ãããããªãã©ãããã©ãŒã ã¯ãããŸããã å®éãprisma.ioãéåžžã«å€§ããªåœ¹å²ãæãããŠããããããã©ãããã©ãŒã ãprisma-cmsãšåŒãã§ããŸãã
å®éãprisma.ioã¯SaaSãããžã§ã¯ãã§ããã倧ããªèŠåããããŸãã圌ãã¯ãè¡ãããšã®ã»ãšãã©ãã¹ãŠãgithubã«é
眮ããŸãã ã€ãŸããéåžžã«ãªãŒãºããã«ãªæéã§ãµãŒããŒã䜿çšããïŒæ°åã§ç¬èªã®ããŒã¿ããŒã¹ãšAPIãæ§æããïŒããšããèªå®
ã§ãã¹ãŠãå®å
šã«å±éããããšãã§ããŸãã ãã®å Žåãããªãºã ã¯è«ççã«2ã€ã®éèŠãªå¥åã®éšåã«åå²ããå¿
èŠããããŸãã
- Prisma-serverãã€ãŸãããŒã¿ããŒã¹ãå転ããŠãããµãŒããŒã
- ããªãºãã¯ã©ã€ã¢ã³ãã åºæ¬çã«ã¯ãµãŒããŒã§ããããŸãããããŒã¿ãœãŒã¹ïŒprisma-serverïŒã«é¢ããŠã¯ã¯ã©ã€ã¢ã³ãã§ãã
次ã«ããã®çŽããããç¶æ³ã«ã€ããŠèª¬æããŸãã äžè¬ã«ãããªãºã ã®æ¬è³ªã¯ãåäžã®APIãšã³ããã€ã³ãã䜿çšããŠãããŸããŸãªããŒã¿ãœãŒã¹ãæäœã§ããããšã§ãã ã¯ããããã§ã¯èª°ããGraphQLãæãã€ãããšèšãã§ããããprismaã¯ããã§ã¯å¿
èŠãããŸããã äžè¬çã«ã誰ããæ£ããã§ãããããé倧ãªãã€ã³ãããããŸãïŒGraphQLã¯ååãšå
šäœçãªäœæ¥ã®ã¿ãå®çŸ©ããŸãããããèªäœã§ã¯æçµçãªããŒã¿ãœãŒã¹ã䜿çšããäœæ¥ãæäŸããŸããã 圌ã¯ãããŠãŒã¶ãŒãéä¿¡ã§ãããªã¯ãšã¹ããèšè¿°ããAPIãäœæã§ããŸããããããã®ãªã¯ãšã¹ããã©ã®ããã«åŠçãããã¯ãŠãŒã¶ãŒã決ããå¿
èŠããããŸããã ãããŠãã¡ãããããªãºã ãGraphQLã䜿çšããŸãïŒã¡ãªã¿ã«ãããŸããŸãªã¢ãã補åãå«ãä»ã®å€ãã®ãã®ïŒã ããããããã«å ããŠããªãºã ã¯ãããŒã¿ããŒã¹ã§ã®äœæ¥ãæäŸããã ãã§ãã ã€ãŸããã¹ããŒã ãšãã®ãããã€ã¡ã³ãã«ã€ããŠèª¬æãããšãå¿
èŠãªããŒãã«ãšåïŒããã³ãããã®éã®é¢ä¿ïŒãæå®ãããããŒã¿ããŒã¹ã«ããã«äœæãããå¿
èŠãªãã¹ãŠã®CRUDé¢æ°ãããã«çæãããŸãã ã€ãŸããããªãºã ã䜿çšãããšãGraphQLãµãŒããŒã ãã§ãªããããã«ããŒã¿ããŒã¹ãæäœã§ããå®å
šã«æ©èœããAPIãååŸã§ããŸãã ãããã£ãŠãPrisma-serverã¯ããŒã¿ããŒã¹ãšããŒã¿ããŒã¹ãšã®çžäºäœçšãæäŸããprisma-clientã䜿çšãããšããªãŸã«ããŒãèšè¿°ããprisma-serverïŒãŸãã¯ããã€ãã®prisma-ãµãŒããŒã§ãïŒã«ãªã¯ãšã¹ããéä¿¡ã§ããŸãã ãããã£ãŠãprisma-clientã¯èªåã§ãããããã€ã§ããªãïŒãããŠSaaS prisma.ioãprisma-serverãšããŠäœ¿çšãããïŒããšãã§ããprisma-serverãèªåã§ãããã€ã§ããéåžžã¯ããªãºã ã«ãŸã£ããäŸåãããããããã¹ãŠã§ãããªãã®ãã®ã
ããã§ã¯ããã©ãããã©ãŒã ã®åºç€ãšããŠãããªãºã ãèªåçšã«éžæããŸããã ããããããããå®å
šãªãã©ãããã©ãŒã ãåŸãããã«èªåã§ãããã¹ãã³ããªããã°ãªããŸããã§ããã
1.ã¹ããŒã ã®ããŒãž
åœæãããªãºã ã¯åè·¯ãçµã¿åãããããšãã§ããŸããã§ããã ã€ãŸããã¿ã¹ã¯ã¯æ¬¡ã®ãšããã§ãã
1ã€ã®ã¢ãžã¥ãŒã«ã«èšè¿°ããããŠãŒã¶ãŒã¢ãã«ããã
type User { id: ID! @unique username: String! @unique email: String @unique }
ãããŠå¥ã®ã¢ãžã¥ãŒã«ã§
type User { id: ID! @unique username: String! @unique firstname: String lastname: String }
1ã€ã®ãããžã§ã¯ãã®äžéšãšããŠãããã2ã€ã®ã¹ããŒã ãèªåçã«çµã¿åãããŠåºåãååŸããŸãã
type User { id: ID! @unique username: String! @unique email: String @unique firstname: String lastname: String }
ãããããã®åŸããã®ããªãºã ã¯ã§ããŸããã§ããã
merge-graphql-schemasã©ã€ãã©ãªã䜿çšããŠãããå®è£
ããããšãå€æããŸããã
ä»»æã®ããªãºã ãµãŒããŒã§åäœããŸãã
ããªãºã ã§ã¯ãæ§æã¯ç¹å¥ãªæ§æãã¡ã€ã«ã«æžã蟌ãŸããŸãã 䜿çšãããŠããããªãºã ãµãŒããŒã®ã¢ãã¬ã¹ãå€æŽããå Žåã¯ããã¡ã€ã«ãç·šéããå¿
èŠããããŸãã äºçŽ°ãªããšã§ãå¿«é©ã§ã¯ãããŸããã ããšãã°ãendpoint = httpïŒ// endpoint-address yarn deployïŒyarn startïŒã®ããã«ãã³ãã³ãã§URLãæå®ã§ããããã«ããŸããã ããã¯æ°æ¥é殺ãããŸãã...ããããä»ã§ã¯ã1ã€ã®ããªãºã ãããžã§ã¯ããä»»æã®æ°ã®ãšã³ããã€ã³ãã«äœ¿çšã§ããŸãã ãšããã§ãprisma-cmsã¯ããŒã«ã«ããŒã¿ããŒã¹ã§ããSaaSããªãºã ãµãŒããŒã§ãç°¡åã«æ©èœããŸãã
ã¢ãžã¥ãŒã«/ãã©ã°ã€ã³
ããã¯äžè¬ã«ååã§ã¯ãããŸããã§ããã ç§ãèšã£ãããã«ãããªãºã ã®äž»ãªã¿ã¹ã¯ã¯ãããŸããŸãªããŒã¿ããŒã¹ã§äœæ¥ãæäŸããããšã§ãã ãããŠã圌ãã¯ããã«ã€ããŠçŽ æŽãããä»äºãããŠããŸãã æ¢ã«ãMySQLãPostgreSQLãAmazon RDSãMongoDBãããã«ããã€ãã®çš®é¡ã®ãœãŒã¹ã®äœ¿çšããµããŒãããŠããŸãã ãã ããã¢ãžã¥ãŒã«åŒã€ã³ãã©ã¹ãã©ã¯ãã£ã¯æäŸããŸããã ãããŸã§ã®ãšãããåžå Žãªã©ã¯ãããŸããã å
žåçãªãã©ã³ã¯ã¯ãããããã§ãã ãã ããè€æ°ã®ãã©ã³ã¯ãã2ã€ãŸãã¯3ã€ãéžæããŠã1ã€ã®ãããžã§ã¯ãã«ã€ã³ã¹ããŒã«ããããšã¯ã§ããŸããã ãããããéžæããå¿
èŠããããŸãã æçµãããžã§ã¯ãã«ç°ãªãæ°ã®ã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ã§ããããã«ããåè·¯ãšãªãŸã«ããŒãå±éãããšãã«ãæ©èœããã¹ãŠåãããã®ãããªåäžã®ãããžã§ã¯ãã楜ãããªãããã«ãããã£ãã®ã§ãã ãŸããã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ã¯ãŸã ãããŸããããæçµãããžã§ã¯ãã§çµã¿åãããããšãã§ãã20以äžã®äœæ¥ã¢ãžã¥ãŒã«ãšã³ã³ããŒãã³ããæ¢ã«ãããŸãã ããã§å人çãªå®çŸ©ã«ã€ããŠå°ã決å®ããŸããã¢ãžã¥ãŒã«ã¯èé¢ã«ã€ã³ã¹ããŒã«ããããã®ïŒããŒã¿ããŒã¹ãšAPIãæ¡åŒµããïŒã§ãããã³ã³ããŒãã³ãã¯åé¢ã«ã€ã³ã¹ããŒã«ããããã®ïŒããŸããŸãªã€ã³ã¿ãŒãã§ãŒã¹èŠçŽ ãè¿œå ããããïŒã§ãã ãããŸã§ã®ãšãããã¢ãžã¥ãŒã«ãæ¥ç¶ããããã®ã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ã¯ãããŸãããããã®æ¹æ³ã§æžãããšã¯é£ãããããŸããïŒããã¯ããè¡ãããŸããïŒã
constructor(options = {}) { super(options); this.mergeModules([ LogModule, MailModule, UploadModule, SocietyModule, EthereumModule, WebrtcModule, UserModule, RouterModule, ]); }
æ°ããã¢ãžã¥ãŒã«ãè¿œå ããåŸãåã«1ã€ã®ã³ãã³ãã§ãããã€ãå®è¡ããã ãã§ååã§ããããã§ã¯ãæ°ããããŒãã«/åãšæ¡åŒµæ©èœãæ¢ã«ãããŸãã
5ããã¯ãšã³ãã®å€æŽã«å¯Ÿå¿ããããã³ã
ããã¯ãŸã£ããååã§ã¯ãããŸããã§ããã ããã«äœè«ããããŸãã å®éã®ãšãããç§ãèŠããã¹ãŠã®APIãã¡ãŒã¹ãCMSã¯ããAPIãæäŸããã®ã¯çŽ æŽãããããšã§ãããããªãã¯æåç·ã«æããã®ãå°ç¡ãã«ããŠããŸãããšããããšã§ãã ããã¯åœŒãã®ãããªããæããã®ã¯äœã§ããããã§ãããå®éããããªããæãããã«ä»²éããæå³ããŸãã UIãã¬ãŒã ã¯ãŒã¯ãèšãã®ãšãŸã£ããåãã§ããã¯ãŒã«ãªãã¿ã³ãèŠãŠãããããã¹ãŠå®è¡ããèªåèªèº«ã§ããã¯ãšã³ããšæ··åããŸãããšèšããŸãã ããã¯åžžã«æ®ºãããã GraphQLã䜿çšããååŸã®äž¡æ¹ãæäŸãããjavascriptã§èšè¿°ãããå
æ¬çãªCMSãèŠã€ãããã ãã§ãã ããããç§ã¯ãã®ãããªãã®ãèŠã€ããŸããã§ããã APIã®å€æŽãããã«ããã³ãã§èªèãããããã«ãããã£ãã®ã§ãã ãã®ãããããã€ãã®ãµãã¹ããããå®äºããŸããã
5.1 APIãã©ã°ã¡ã³ãã®çæ
åé¢ã§ã¯ãã¹ããŒããã¡ã€ã«ã®ãã©ã°ã¡ã³ãããªã¯ãšã¹ãã«ç»é²ãããŸãã ãµãŒããŒäžã§APIãåæ§ç¯ããããšãAPIãã©ã°ã¡ã³ããå«ãæ°ããJSãã¡ã€ã«ãçæãããŸãã ãããŠããªã¯ãšã¹ãã§ã¯æ¬¡ã®ããã«æžãããŠããŸãïŒ
const { UserNoNestingFragment, EthAccountNoNestingFragment, NotificationTypeNoNestingFragment, BatchPayloadNoNestingFragment, } = queryFragments; const userFragment = ` fragment user on User { ...UserNoNesting EthAccounts{ ...EthAccountNoNesting } NotificationTypes{ ...NotificationTypeNoNesting } } ${UserNoNestingFragment} ${EthAccountNoNestingFragment} ${NotificationTypeNoNestingFragment} `; const usersConnection = ` query usersConnection ( $where: UserWhereInput $orderBy: UserOrderByInput $skip: Int $after: String $before: String $first: Int $last: Int ){ objectsConnection: usersConnection ( where: $where orderBy: $orderBy skip: $skip after: $after before: $before first: $first last: $last ){ aggregate{ count } edges{ node{ ...user } } } } ${userFragment} `;
5.2ãã¹ãŠã®ã³ã³ããŒãã³ãã«1ã€ã®ã³ã³ããã¹ã
React 16.3ã§ã¯ã
æ°ããã³ã³ããã¹ãAPIãå°å
¥ãããŠã
ãŸã ã ä»»æã®ã¬ãã«ã®åã³ã³ããŒãã³ãã§ãã³ã³ããã¹ãããäºåã«å¿
èŠãªã¿ã€ãããªã¹ãããã«åäžã®ã³ã³ããã¹ãã«ã¢ã¯ã»ã¹ã§ããããã«ããŸããããåã«éçcontextType = PrismaCmsContextãæå®ããthis->ã³ã³ããã¹ãïŒAPIã¯ã©ã€ã¢ã³ããã¹ããŒã ãå«ãïŒ ããªã¯ãšã¹ããªã©ïŒã
5.3åçãã£ã«ã¿ãŒ
ç§ãæ¬åœã«ããããã£ãã GraphQLã䜿çšãããšããã¹ããããæ§é ãæã€è€éãªã¯ãšãªãäœæã§ããŸãã ãã£ã«ã¿ãŒãåçã§ãAPIã¹ããŒã ãã圢æããããã¹ããããæ¡ä»¶ãäœæã§ããããã«ãããã£ãã®ã§ãã èµ·ãã£ãããšã¯æ¬¡ã®ãšããã§ãã
5.4ãŠã§ããµã€ããã«ããŒ
ãããŠæåŸã«ãç§ãæ¬ ããŠããã®ã¯å€éšãµã€ãç·šéè
ãã€ãŸããã¶ã€ããŒã§ããã ãµãŒããŒäžã§æå°éã®ã¢ã¯ã·ã§ã³ã®ã¿ãå®è¡ãããã£ããããæçµçãªèšèšã¯ãã¹ãŠããã³ãã§è¡ãå¿
èŠããããŸãïŒã«ãŒãã£ã³ã°ã®èšå®ãéžæã®çæãªã©ïŒã ããã¯å¥ã®èšäºã®ãããã¯ã§ããäœããããçŽç²ãªcontentEditableã§ãç§ã¯ããã®ããã«ç§ã®wrutch wysiwygãšãã£ã¿ãŒãæžããã®ã§ãå€ãã®åŸ®åŠãªç¹ããããŸãã èªåã®æš©å©ãå埩ããèå³ã®ãã人ãããå Žåã¯ãå¥ã®èšäºãæžããŸãã
ããŠãæåŸã«ãåäœäžã®ãã¶ã€ããŒã®çããã¢ãããªã ãŸã çã§ãããç§ã¯ããã奜ãã§ãã
ãããçµãããŸã§ã æžãããããšã¯ãŸã æžããŠããŸããããããããã®ããšãèµ·ãããŸããã ã³ã¡ã³ããããŠããã ããŸãã
PSïŒãµã€ãèªäœã®ãœãŒã¹ã³ãŒããå«ããã¹ãŠã®ãœãŒã¹ã³ãŒã
ã¯ãã¡ãã§ãã