๐๐ฝโโ๏ธ CMS ๋ถ๊ฐ์ง๋ก ์ ์ง์ํ๊ธฐ ์ํด Gato GraphQL์ด ์ฝ 90๊ฐ์ ํจํค์ง๋ก ๋ถํ ๋ ์ด์ ์ ์ด ์ ๊ทผ ๋ฐฉ์์ ์ฅ๋จ์
์ง๋ ์ฃผ์ ๐๐ปโโ๏ธ Gato GraphQL์ด ์ ๋ชจ๋
ธ๋ ํฌ๊ฐ ํ์ํ์ง, ๊ทธ๋ฆฌ๊ณ ์ด๋ป๊ฒ ์ต์ ํ๋์ด ์๋์ง ๋ผ๋ ๊ธ์ ๊ฒ์ฌํ์ต๋๋ค. Gato GraphQL์ ์ฝ๋๋ฅผ ํธ์คํ
ํ๋ GatoGraphQL/GatoGraphQL ๋ชจ๋
ธ๋ ํฌ๊ฐ ํ๋ฌ๊ทธ์ธ์ ์ฝ๋๋ฒ ์ด์ค๋ฅผ ์ผ๋ง๋ ํจ์จ์ ์ผ๋ก ๊ด๋ฆฌํ ์ ์๋์ง์ ๋ํด ์ค๋ช
ํ์ต๋๋ค.
์ด ๊ธ์ Reddit์ ๊ณต์ ํ๋๋ ๋ค์๊ณผ ๊ฐ์ ๋๊ธ์ ๋ฐ์์ต๋๋ค.
OP์ ๊ธ๊ณผ ๊ฑฐ๊ธฐ์ ๋งํฌ๋ ๊ธ๋ค์ ์ฝ์ผ๋ฉด, ๋ง์น ๋ชจ๋ ธ๋ ํฌ๊ฐ ์ฌ๋ผ์ด์ค ๋นต ์ดํ ์ต๊ณ ์ ๋ฐ๋ช ์ธ ๊ฒ์ฒ๋ผ ์ฝํ๋๋ค.
๋ ํฅ๋ฏธ๋ก์ด ๊ธ์ด๋ผ๋ฉด, ์ CMS ๋ถ๊ฐ์ง๋ก ์ ์ํด ๋ชจ๋ ๊ฒ์ ๊ฐ๊ฐ์ ์์ ํจํค์ง๋ก ๋ถ๋ฆฌํด์ผ ํ๋ค๊ณ ์๊ฐํ๋์ง, ๊ทธ๋ฆฌ๊ณ ์ 200๊ฐ ์ด์์ ํจํค์ง ๊ฐ๊ฐ์ ์ฒ์๋ถํฐ ๋ ๋ฆฝ๋ ์ ์ฅ์์ ๋์ด์ผ ํ๋ค๊ณ ์๊ฐํ๋์ง๋ฅผ ์ค๋ช ํ๋ ๊ฒ์ด๊ฒ ์ฃ .
์ด๊ฒ์ ํฅ๋ฏธ๋ก์ด ์ง๋ฌธ์ ๋๋ค. ๊ทธ๋์ ์ด ๊ธ์ ์์ฑํ์ฌ ์ข ๋ ์์ธํ ๋ค๋ฃจ๊ธฐ๋ก ํ์ต๋๋ค.
ํ์ง๋ง ๋จผ์ , ๊ด๋ จ๋ ๋ ๊ฐ์ง ์ฃผ์ ๋ฅผ ๋ค๋ฃจ๊ฒ ์ต๋๋ค. ํ๋ฌ๊ทธ์ธ์ด ์ค์ ๋ก ํ์๋ก ํ๋ ํจํค์ง์ ์์, ๊ธฐ๋ฐ์ด ๋๋ GraphQL ์๋ฒ๊ฐ CMS ๋ถ๊ฐ์ง๋ก ์ ์ด๋ผ๊ณ ์ฃผ์ฅํ๋ ์ด์ ์ ๋๋ค.
ํ๋ฌ๊ทธ์ธ์ ๊ตฌ์ฑํ๋ ํจํค์ง์ ์
200๊ฐ ์ด์์ PHP ํจํค์ง๋ฅผ ์ธ๊ธํ์ง๋ง, ๊ทธ๊ฒ์ ๋ชจ๋ ธ๋ ํฌ์ ๊ดํ ๊ฒ์ ๋๋ค. ํ๋ฌ๊ทธ์ธ์ ๊ดํด์๋ ์ค์ ๋ก ๊ทธ๋ณด๋ค ํจ์ฌ ์ ์ต๋๋ค.
GatoGraphQL/GatoGraphQL ๋ชจ๋
ธ๋ ํฌ๋ 5๊ฐ์ ํ๋ก์ ํธ๋ฅผ ํฌํจํ๊ณ ์์ต๋๋ค:
- PoP: ์๋ฒ ์ฌ์ด๋ ์ปดํฌ๋ํธ ๋ชจ๋ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ (React์ ์ ์ฌํ์ง๋ง ๋ฐฑ์๋์ฉ)
- GraphQL by PoP: PHP๋ฅผ ์ํ CMS ๋ถ๊ฐ์ง๋ก ์ GraphQL ์๋ฒ
- Gato GraphQL
- ์ฌ์ดํธ ๋น๋ (WIP)
- Wassup: ์ฌ์ดํธ ๋น๋ ๊ธฐ๋ฐ์ ์น์ฌ์ดํธ ํ ๋ง (WIP)
์ด๋ฌํ ํ๋ก์ ํธ๋ค์ ๋ชจ๋ ธ๋ ํฌ์์ ํธ์คํ ํ๋ฉด ์ํธ ์์กด์ฑ ๋๋ฌธ์ ์์ ์ด ๊ฐํธํด์ง๋๋ค:
- GraphQL by PoP๋ PoP๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค
- Gato GraphQL์ GraphQL by PoP๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค
- ์ฌ์ดํธ ๋น๋๋ ์ปดํฌ๋ํธ ๋ชจ๋ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์์ง์ผ๋ก ์ฌ์ฉํฉ๋๋ค (Gatsby๊ฐ GraphQL์ ์ฌ์ฉํ๋ ๋ฐฉ์๊ณผ ์ ์ฌ)
- Wassup์ ์ฌ์ดํธ ๋น๋๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค
5๊ฐ ํ๋ก์ ํธ ๋ชจ๋์ ์ฝ๋์ ๊ด๋ จํ์ฌ, GatoGraphQL/GatoGraphQL์ 200๊ฐ ์ด์์ PHP ํจํค์ง๋ฅผ ํฌํจํ๊ณ ์์ต๋๋ค. Gato GraphQL์ ๊ดํด์๋ "๋จ์ง" 91๊ฐ์ ํจํค์ง์
๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ธฐ๋ฐ์ด ๋๋ GraphQL ์๋ฒ์ธ GraphQL by PoP๋ "๋จ์ง" 98๊ฐ์ ํจํค์ง๋ฅผ ํฌํจํ๊ณ ์์ต๋๋ค.
(Gato GraphQL ํ๋ฌ๊ทธ์ธ์ด ๊ธฐ๋ฐ GraphQL ์๋ฒ๋ณด๋ค ์ ์ ํจํค์ง๋ฅผ ํ์๋ก ํ๋ ์ด์ ๋, Google Translate @strTranslate ๋๋ ํฐ๋ธ์ ๊ฐ์ ์ผ๋ถ ํจํค์ง๊ฐ ์์ง ํ๋ฌ๊ทธ์ธ์ ์ถ๊ฐ๋์ง ์์๊ธฐ ๋๋ฌธ์
๋๋ค.)
GraphQL by PoP๋ ์ด๋ป๊ฒ CMS ๋ถ๊ฐ์ง๋ก ์ ์ธ๊ฐ์? webonyx์์ ์ฐจ์ด๋ ๋ฌด์์ธ๊ฐ์?
GraphQL by PoP๋ CMS ๋ถ๊ฐ์ง๋ก ์ ์ด๋ผ๊ณ ๋งํด์์ต๋๋ค. ํ์ง๋ง ๊ทธ๊ฒ์ด ๋ฌด์จ ์๋ฏธ์ธ๊ฐ์?
๊ทธ๋ฐ๋ฐ webonyx/graphql-php๋ CMS ๋ถ๊ฐ์ง๋ก ์ ์
๋๋ค. ๊ทธ๋ ๋ค๋ฉด ๋ ๊ฐ์ง๋ ์ด๋ป๊ฒ ๋ค๋ฅผ๊น์?
webonyx/graphql-php๊ฐ CMS ๋ถ๊ฐ์ง๋ก ์ ์ธ ๊ฒ์, Composer๋ฅผ ํตํด ๋ฐฐํฌ๋๋ ํจํค์ง๋ก์ "๋ฐ๋๋ผ" PHP ์ฝ๋๋ง์ ํฌํจํ๊ณ ์๋ค๋ ์๋ฏธ์์์
๋๋ค. ํ์ง๋ง ๊ทธ ์์ฒด๋ก๋ ์์ ํ GraphQL ์๋ฒ๊ฐ ์๋๋ฉฐ, PHP์์ GraphQL ์ฌ์์ ๊ตฌํํ ๊ฒ์ผ๋ก, PHP์ ์ด๋ค GraphQL ์๋ฒ์ ๋ด์ฅ๋๋๋ก ์ค๊ณ๋์ด ์์ต๋๋ค.
์ด์ Lighthouse๋ WPGraphQL๊ณผ ๊ฐ์ด GraphQL์ ๊ตฌํํ๋ ์๋ฒ๋ค์ CMS ๋ถ๊ฐ์ง๋ก ์ ์ด์ง ์์ต๋๋ค. Lighthouse๋ฅผ WordPress์์ ์คํํ๊ฑฐ๋, WPGraphQL์ Laravel์์ ์คํํ ์ ์์ต๋๋ค.
์ด๋ฐ ์๋ฏธ์์ GraphQL by PoP๋ CMS ๋ถ๊ฐ์ง๋ก ์ ์ ๋๋ค: Laravel, WordPress, ๋๋ ๊ธฐํ ์ด๋ค CMS๋ ํ๋ ์์ํฌ์์๋ ์คํํ ์ ์๋๋ก ๊ฑฐ์ ์ค๋น๋ "์ค์์ฑํ" GraphQL ์๋ฒ์ ๋๋ค. (๊ฐ๊ฒฐํจ์ ์ํด, ์ดํ๋ถํฐ "CMS"๋ "CMS ๋๋ ํ๋ ์์ํฌ"๋ฅผ ์๋ฏธํฉ๋๋ค.)
ํน์ CMS๋ฅผ ์ํด ์์ฑํ๋ ค๋ฉด, ํด๋น GraphQL ์๋ฒ์๋ ํด๋น ํจํค์ง๋ฅผ ํตํด ๊ทธ CMS์ ๋ง๋ ์ปค์คํ ์ฝ๋๊ฐ ์ฌ์ ํ ํ์ํฉ๋๋ค.
์ด์ ๋๊ธ์ ์ง๋ฌธ์ ๋ตํ๊ฒ ์ต๋๋ค.
์ ๊ฐ ํจํค์ง๋ฅผ ๋ ๋ฆฝ๋ ์ ์ฅ์์ ๋์ด์ผ ํ๋์?
Packagist (Composer์ PHP ํจํค์ง ๋ ์ง์คํธ๋ฆฌ)๊ฐ ํจํค์ง๋ฅผ ๊ฒ์/๋ฐฐํฌํ๊ธฐ ์ํด ์ ์ฅ์ URL ์ ๊ณต์ ์๊ตฌํ๊ธฐ ๋๋ฌธ์ ๋๋ค.
(์ฐธ๊ณ ๋ก, ์ญ์ ์ง๋ ์ฃผ์ ๊ฒ์ฌํ ์ ์ ๊ธ Hosting all your PHP packages together in a monorepo์์๋ ์ด ๋ฌธ์ ์ ๋ํด ๋ค๋ฃจ๊ณ ์์ต๋๋ค.)
์ CMS ๋ถ๊ฐ์ง๋ก ์ ์ํด ๋ชจ๋ ๊ฒ์ ๊ฐ๊ฐ์ ์์ ํจํค์ง๋ก ๋ถ๋ฆฌํด์ผ ํ๋์?
๋ช ๊ฐ์ง ์ด์ ๊ฐ ์์ต๋๋ค.
CMS๊ฐ ์์ฒด ์ฝ๋๋ฅผ ์ฃผ์ ํ ์ ์๋๋ก ํ๊ธฐ
100% ๋์ผํ PHP ์ฝ๋๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋์๋ ์๋ํ๋ GraphQL ์๋ฒ๋ฅผ ๋ง๋๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํฉ๋๋ค.
์๋ฅผ ๋ค์ด, ์ฝ๋์ ์ผ๋ถ๊ฐ ๋ค๋ฅธ ๊ณณ์ ๋ณ์ ๊ฐ์ ์์ ํ ์ ์๋๋ก ํ๊ธฐ ์ํด, WordPress๋ ํํฐ ํ ์ ์์กดํ๊ณ , Symfony๋ EventDispatcher ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํ๋ฉฐ, Laravel์๋ ์์ฒด์ ์ธ ์ด๋ฒคํธ์ ๋ฆฌ์ค๋ ์์คํ ์ด ์์ต๋๋ค. ์ด ์ธ ๊ฐ์ง ๋ค๋ฅธ ๋ฐฉ๋ฒ์ PHP ์ฝ๋๋ ์๋ก ๋ค๋ฆ ๋๋ค.
์ฌ๊ธฐ์ ์ฝ๋๋ฅผ ์ธ๋ถํ๋ ํจํค์ง๋ก ๋ถํ ํ๋ ์ ๊ทผ ๋ฐฉ์์ด ๋ฑ์ฅํฉ๋๋ค. ์ด๋ฒคํธ์ ๋ฆฌ์ค๋์ ๋ํ ์๋ฃจ์ ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ผ๋ถ๋ก ํฌํจํ๋ ๋์ , ํจํค์ง๋ฅผ ํตํด ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฃผ์ ๋๋ฉฐ, ์ด ํจํค์ง์๋ CMS๋ณ ์ฝ๋๊ฐ ํฌํจ๋ฉ๋๋ค.
์ด๊ฒ์ด ์๋ํ๋ ค๋ฉด, ๋ชจ๋ ๊ธฐ๋ฅ์ 2๊ฐ์ ํจํค์ง๋ก ๋ถ๋ฆฌํด์ผ ํฉ๋๋ค:
- CMS ๋ถ๊ฐ์ง๋ก ์ ํจํค์ง: ๋ชจ๋ ๋น์ฆ๋์ค ๋ก์ง์ ํฌํจํ๋ฉฐ "๋ฐ๋๋ผ" PHP ์ฝ๋๋ง ์ฌ์ฉํฉ๋๋ค. ์ด ํจํค์ง์๋ CMS๋ณ ํจํค์ง๊ฐ ์ถฉ์กฑํด์ผ ํ ๊ณ์ฝ์ด ํฌํจ๋ฉ๋๋ค
- CMS๋ณ ํจํค์ง: ํด๋น CMS์ ๋ํ ๊ณ์ฝ์ ์ถฉ์กฑํฉ๋๋ค
์๋ฅผ ๋ค์ด, GraphQL by PoP์๋ ๋ค์๊ณผ ๊ฐ์ ๊ณ์ฝ์ ํฌํจํ๋ hooks ํจํค์ง๊ฐ ์์ต๋๋ค:
interface HooksAPIInterface
{
public function addFilter(string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1): void;
public function removeFilter(string $tag, callable $function_to_remove, int $priority = 10): bool;
public function applyFilters(string $tag, mixed $value, mixed ...$args): mixed;
public function addAction(string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1): void;
public function removeAction(string $tag, callable $function_to_remove, int $priority = 10): bool;
public function doAction(string $tag, mixed ...$args): void;
}๊ทธ๋ฆฌ๊ณ ํจํค์ง hooks-wp๋ WordPress์ ๋ํ ๊ณ์ฝ์ ์ถฉ์กฑํฉ๋๋ค:
class HooksAPI implements HooksAPIInterface
{
public function addFilter(string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1): void
{
\add_filter($tag, $function_to_add, $priority, $accepted_args);
}
public function removeFilter(string $tag, callable $function_to_remove, int $priority = 10): bool
{
return \remove_filter($tag, $function_to_remove, $priority);
}
public function applyFilters(string $tag, mixed $value, mixed ...$args): mixed
{
return \apply_filters($tag, $value, ...$args);
}
public function addAction(string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1): void
{
\add_action($tag, $function_to_add, $priority, $accepted_args);
}
public function removeAction(string $tag, callable $function_to_remove, int $priority = 10): bool
{
return \remove_action($tag, $function_to_remove, $priority);
}
public function doAction(string $tag, mixed ...$args): void
{
\do_action($tag, ...$args);
}
}์ด์ ํ
์ ๊ฐ๋
์ WordPress์์ ์ ๋ํ์ง๋ง, ๋ค๋ฅธ CMS์์๋ ์๋ํ ์ ์์ต๋๋ค (์: ์ด๋ฒคํธ์ ๋ฆฌ์ค๋๋ฅผ ์ฌ์ฉํ์ฌ ํ
์ ๊ตฌํํ๋ ๊ฒฝ์ฐ). ๋ฐ๋ผ์ hooks-wp๋ฅผ hooks-laravel, hooks-symfony, hooks-drupal, hooks-octobercms, ๋๋ ๋ค๋ฅธ ๊ฒ์ผ๋ก ๊ต์ฒดํ์ฌ ๊ฐ CMS๋ณ ์ฝ๋๋ฅผ ์ฌ์ฉํด ๊ณ์ฝ์ ์ถฉ์กฑํ ์ ์์ต๋๋ค.
CMS๊ฐ ์ง์ํ ์ ์๋ ๊ธฐ๋ฅ์ ์ ๊ฑฐํ ์ ์๋๋ก ํ๊ธฐ
๋ชจ๋ CMS๊ฐ ๋ชจ๋ ๊ธฐ๋ฅ์ ์ง์ํ ์ ์๋ ๊ฒ์ ์๋๋๋ค. ์๋ฅผ ๋ค์ด, WordPress๋ meta_value ํญ๋ชฉ์ผ๋ก ๊ฒ์๋ฌผ์ ์ ๋ ฌํ๋ ๊ฒ์ ๊ฐ๋ฅํ๊ฒ ํ์ง๋ง, OctoberCMS๋ ๊ทธ๋ ์ง ์์ต๋๋ค.
๊ทธ๋์ GraphQL by PoP์๋ metaquery ํจํค์ง๊ฐ ์์ต๋๋ค (WordPress๋ฅผ ์ํด metaquery-wp๋ฅผ ํตํด ์ถฉ์กฑ๋ฉ๋๋ค). ๊ทธ๋ฌ๋ฉด WordPress๋ฅผ ์ํด ๊ตฌํ๋ GraphQL ์๋ฒ๋ ์ด ํจํค์ง๋ฅผ ํฌํจํ๊ฒ ์ง๋ง, OctoberCMS๋ฅผ ์ํ ๊ฒ์ ํฌํจํ์ง ์์ ๊ฒ์
๋๋ค.
์ด ์ ๊ทผ ๋ฐฉ์์ ์ฅ์
ํจํค์ง๋ฅผ ์ธ๋ถํํ์ฌ ๋ถํ ํ๋ฉด ๋ช ๊ฐ์ง ์ด์ ์ด ์์ต๋๋ค.
๋น์ฆ๋์ค ๋ก์ง์ CMS๋ณ ์ฝ๋์์ ๋ถ๋ฆฌํ๊ธฐ
CMS์ ํน์ฑ (์ฝ๋ฉ ๋ฐฉ์, ๊ธฐ๋ฅ, ์ ํ ์ฌํญ ๋ฑ)์ ๊ธฐ๋ฐํ์ฌ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฝ๋ฉํ๋ ๋์ , ์ฝ๋๋ฅผ ์ถ์ํํ๊ณ ๋น์ฆ๋์ค ๋ก์ง๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด, ๊ฒ์๋ฌผ ๋ชฉ๋ก์ ๊ฐ์ ธ์ค๊ธฐ ์ํด, ์ ํ๋ฆฌ์ผ์ด์
์ CMS ๋ถ๊ฐ์ง๋ก ์ ํจํค์ง posts์ ์ธํฐํ์ด์ค์์ getPosts ๋ฉ์๋๋ฅผ ์คํํ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ฉด ๊ธฐ๋ฐ CMS์ ์ํ ๊ตฌํ๊ณผ ๋ฌด๊ดํ๊ฒ ๊ฒ์๋ฌผ์ ํญ์ ๊ฐ์ ๋ฐฉ์์ผ๋ก ๊ฐ์ ธ์์ง๋๋ค.
๊ธฐ์ ์ ๋ถ์ฑ๋ฅผ ์ฐํํ๊ณ ์ต์ ํ์ค ์ฌ์ฉํ๊ธฐ
์์ ์๋ฅผ ์ด์ด์, PSR-4 ๊ท์ฝ์ ๋ฐ๋ฅด๋ getPosts ๋ฉ์๋๋ฅผ ์คํํ์ฌ ๊ฒ์๋ฌผ์ ๊ฐ์ ธ์ต๋๋ค. WordPress์์ ์ ์ํ get_posts๋ฅผ ํธ์ถํ๋ ๋์ ์ ๋ง์ด์ฃ .
๋ง์ฐฌ๊ฐ์ง๋ก, ๋ถ์ ํํ get_post ๋์ getCustomPost๋ฅผ ์คํํ์ฌ ์ปค์คํ
๊ฒ์๋ฌผ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค (์ด๊ฒ์ WordPress์ ๊ธฐ์ ์ ๋ถ์ฑ์ ์ผ๋ถ์
๋๋ค).
์ค์ฝํ ์ ์ฉ์ด ์ฝ๋ค
WordPress ํ๋ฌ๊ทธ์ธ์ PHP-Scoper๋ฅผ ์ฌ์ฉํ์ฌ ์ค์ฝํ๋ฅผ ์ ์ฉํ๋ ๊ฒ์ ์ฝ์ง ์์ผ๋ฉฐ, ๊ฐ๋ฅํ ๊ฒฝ์ฐ์๋ ๋ฒ๊ทธ๊ฐ ๋ฐ์ํ๊ธฐ ์ฝ์ต๋๋ค.
CMS๋ณ ์ฝ๋์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋น์ฆ๋์ค ๋ก์ง์ ์ฒ ์ ํ ๋ถ๋ฆฌํ๋ฉด, ์ผ๋ถ ํจํค์ง (๋น์ฆ๋์ค ๋ก์ง์ด ์๋ ๊ฒ)์๋ง PHP-Scoper๋ฅผ ์ ์ฉํ๊ณ ๋ค๋ฅธ ํจํค์ง (WordPress ์ฝ๋๋ฅผ ํฌํจํ๋ ๊ฒ)์๋ ์ ์ฉ์ ํผํ ์ ์์ต๋๋ค. ์ด ์ ๋ต์ ๋ํด ์ฌ๊ธฐ์์ ์์ธํ ์ค๋ช ํ์ต๋๋ค.
๋ํ, PHP-Scoper์ ์ ์ฌํ๊ฒ, ์ผ๋ถ CMS๋ณ ์ฝ๋ (WordPress ๋ฑ)์ ์ ์ฉํ๋ฉด ์คํจํ๋ ๋ค๋ฅธ ๋๊ตฌ๋ค๋ ์์ ์ ์์ต๋๋ค. ๊ทธ๋ฐ ๊ฒฝ์ฐ์๋ ํจํค์ง๋ฅผ ์ธ๋ถํํ์ฌ ๋ถํ ํ๋ ๊ฒ์ด ํด๊ฒฐ์ฑ ์ด ๋ ์ ์์ต๋๋ค.
ํ์ํ ์ฝ๋๋ง ํฌํจํ๋ ๋ค์ํ ์ ํ๋ฆฌ์ผ์ด์ ์ ์์ฑํ ์ ์๋ค
ํจํค์ง๋ฅผ ์ฌ์ฌ์ฉํ์ฌ ํ์ํ ํจํค์ง๋ง ํฌํจํ๋ ์ฌ๋ฌ ์ ํ๋ฆฌ์ผ์ด์ ์ ์์ฑํ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด, ๊ฐ์ธ ๋ธ๋ก๊ทธ๋ posts, tags, categories๋ง ํ์ํ ์ ์์ผ๋ฏ๋ก, users๋ user-login ๊ธฐ๋ฅ์ ๋ค๋ฃฐ ํ์๊ฐ ์์ต๋๋ค.
์ค์ ๋ก, ์ ๋ ๊ณง ์ด ๊ธฐ๋ฅ์ ํ์ฉํ ๊ณํ์ ๋๋ค: ํ์ฌ "Private GraphQL API"๋ฅผ ๊ฐ๋ฐ ์ค์ ๋๋ค. ์ด๊ฒ์ ์์ฒด ์๊ฒฐํ GraphQL ์์ง์ผ๋ก, WordPress ํ๋ฌ๊ทธ์ธ ๊ฐ๋ฐ์๋ค์ด ์์ ์ ํ๋ฌ๊ทธ์ธ์ ๋ฒ๋ค๋ก ํฌํจํ์ฌ Gutenberg ๋ธ๋ก์ GraphQL API๋ฅผ ์ ๊ณตํ ์ ์๊ฒ ํ๋ ๊ฒ์ ๋๋ค.
Gato GraphQL ํ๋ฌ๊ทธ์ธ์์ ํ์ํ์ง ์์ ํจํค์ง (UI, ํด๋ผ์ด์ธํธ, ์ปค์คํ ์๋ํฌ์ธํธ, HTTP ์บ์ฑ, ์์ ์ฟผ๋ฆฌ ๋ฑ์ ๋ค๋ฃจ๋ ๊ฒ๋ค)๋ฅผ ์ ๊ฑฐํ๊ธฐ๋ง ํ๋ฉด "Private GraphQL API"๋ฅผ ์์ฝ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค.
๋ง์ง๋ง์ผ๋ก, ์ค์ฝํ ์ ์ฉ์ด ์ฝ๊ธฐ ๋๋ฌธ์ (์์์ ์ดํด๋ณธ ๊ฒ์ฒ๋ผ), ํ์ํ ๋ชจ๋ ํจํค์ง์ ์ ๋์ฌ๋ฅผ ๋ถ์ผ ์ ์์ผ๋ฏ๋ก, Private GraphQL API๋ ์ถฉ๋ ์์ด ์๋ํ ๊ฒ์ ๋๋ค (2๊ฐ์ ์๋ก ๋ค๋ฅธ ํ๋ฌ๊ทธ์ธ์ด ์๋ก ๋ค๋ฅธ ๋ฒ์ ์ Private GraphQL API๋ฅผ ๋ฒ๋ค๋ก ํฌํจํ ๋ ๋ฐ์ํ ์ ์๋ ์ํฉ).
์ด ์ ๊ทผ ๋ฐฉ์์ ๋จ์
๋๋งํ ๊ฒ๋ ์์ด, ์ด ์ ๊ทผ ๋ฐฉ์์ ์๋ฒฝ๊ณผ๋ ๊ฑฐ๋ฆฌ๊ฐ ์์ต๋๋ค.
๋ ๋ง์ ๋ ธ๋ ฅ์ด ํ์ํ๊ณ ์ฝ๋๊ฐ ์ฅํฉํด์ง๋ค
์ผ๋ฐ์ ์ผ๋ก, ์ ํ๋ฆฌ์ผ์ด์
์ด WordPress์์ ์คํ๋๋ค๋ฉด, ๊ฒ์๋ฌผ ๋ชฉ๋ก์ ๊ฐ์ ธ์ค๊ธฐ ์ํด ๋จ์ํ get_posts๋ฅผ ์คํํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค. ๊ฐ๋จํ๊ณ ์ฝ์ต๋๋ค.
CMS ๋ถ๊ฐ์ง๋ก ์ ์ผ๋ก ๋ง๋ค๋ฉด ์ํฉ์ด ์๋นํ ๋ณต์กํด์ง๋๋ค. ๊ฒ์๋ฌผ ๋ชฉ๋ก์ ๊ฐ์ ธ์ค๋ ค๋ฉด ๋ค์์ ์ํํด์ผ ํฉ๋๋ค:
posts์posts-wpํจํค์ง๋ฅผ ์์ฑํฉ๋๋คpostsํจํค์ง์getPostsํจ์๊ฐ ์๋ ๊ณ์ฝ์ ์์ฑํฉ๋๋คposts-wpํจํค์ง์์get_posts๋ฅผ ํตํด ๊ณ์ฝ์ ์ถฉ์กฑํฉ๋๋ค- ๊ธฐ๋ฅ์ ํญ์ ๊ณ์ฝ์ ํตํด ํธ์ถํ๊ณ ์ง์ ํธ์ถํ์ง ์๋๋ก ํฉ๋๋ค
(์๋นํ ๋์ ํ๋ฅ ๋ก) ์์กด์ฑ ์ฃผ์ ์ด ํ์ํ๋ค
CMS ๋ถ๊ฐ์ง๋ก ์ ํจํค์ง์ ๋ชจ๋ ๊ณ์ฝ๊ณผ CMS๋ณ ํจํค์ง์ ๊ตฌํ์ ๋ฐ์ธ๋ฉํด์ผ ํฉ๋๋ค. ์ ๊ฒฝ์ฐ์๋ Symfony์ DependencyInjection ์ปดํฌ๋ํธ๊ฐ ์ ๊ณตํ๋ ์๋น์ค ์ปจํ ์ด๋๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
์ ๋ ์ด ์ ๊ทผ ๋ฐฉ์์ ๋งค์ฐ ์ข์ํ๋ฉฐ, ์ ํ๋ฆฌ์ผ์ด์ ์ ํฌ๊ฒ ๋จ์ํํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ํ์ง๋ง ๋ชจ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ด ์์กด์ฑ ์ฃผ์ ์ ํ์๋ก ํ์ง๋ ์์ผ๋ฉฐ, ๊ทธ๋งํผ ๋ณต์ก์ฑ์ด ์ถ๊ฐ๋๋ค๋ ๊ฒ์ ์ดํดํฉ๋๋ค.
(๊ฐ์ฅ ๋์ ํ๋ฅ ๋ก) ๋ชจ๋ ธ๋ ํฌ๊ฐ ํ์ํ๋ค
Gato GraphQL์ ๊ฒฐ๊ตญ 91๊ฐ์ ํจํค์ง๋ฅผ ํฌํจํ๊ฒ ๋์์ต๋๋ค. ๊ณผ๊ฑฐ์๋ ๊ฐ๊ฐ์ ๋ ๋ฆฝ๋ ์ ์ฅ์์ ํธ์คํ ํ์ฌ PR์ ๋ง๋ค๊ธฐ๊ฐ ๋งค์ฐ ์ด๋ ค์ ์ต๋๋ค. ๊ทธ๋์ ๋ชจ๋ ธ๋ ํฌ ๋ฐฉ์์ผ๋ก ์ ํํ์ง ์์ ์ ์์์ต๋๋ค.
๋ช ํํ ๋ง์๋๋ฆฌ์๋ฉด: ์ ๋ ๋ชจ๋ ธ๋ ํฌ๋ฅผ ์ ๋ง ์ข์ํฉ๋๋ค. ํ์ง๋ง ๋ชจ๋ ์ฌ๋์ด ๊ทธ๊ฒ์ ์ข์ํ๋ ๊ฒ์ ์๋๋ฉฐ, ์ ์งํ๊ธฐ ์ํ ์์ฒด์ ์ธ ๋ ธ๋ ฅ๋ ํ์ํ๋ค๋ ๊ฒ์ ์ดํดํฉ๋๋ค.
์ ์ฉํ ๋งํฌ
์ ๋ WordPress ์น์ฌ์ดํธ๋ฅผ ์ถ์ํํ์ฌ CMS ๋ถ๊ฐ์ง๋ก ์ ์ผ๋ก ๋ง๋ค๊ธฐ ์ํ ๋๊ธฐ์ ์ ๋ต์ ๋ํด ์ด์ ์ ์์ฑํ์ต๋๋ค. Gato GraphQL์ ์ฝ๋๋ฒ ์ด์ค๋ฅผ ๋ถํ ํ๋ ๋ฐ ์ ์ฉํ ๊ฒ์ด ๋ฐ๋ก ์ด ๋์ผํ ์ ๋ต์ ๋๋ค:
- Abstracting WordPress Code To Reuse With Other CMSs: Concepts (Part 1)
- Abstracting WordPress Code To Reuse With Other CMSs: Implementation (Part 2)
๋ถ๋ก: ํ๋ฌ๊ทธ์ธ์ ๊ตฌ์ฑํ๋ 91๊ฐ ํจํค์ง ๋ชฉ๋ก
Gato GraphQL์๋ ๋ค์ 91๊ฐ์ ํจํค์ง๊ฐ ํฌํจ๋์ด ์์ต๋๋ค.
์์ง ๊ธฐ๋ฅ:
getpop/access-control
getpop/cache-control
getpop/component-model
getpop/definitions
getpop/engine
getpop/engine-wp
getpop/field-query
getpop/guzzle-helpers
getpop/hooks
getpop/hooks-wp
getpop/loosecontracts
getpop/mandatory-directives-by-configuration
getpop/modulerouting
getpop/query-parsing
getpop/root
getpop/routing
getpop/routing-wp
getpop/translation
getpop/translation-wp
graphql-api/markdown-convertor
API ๊ธฐ๋ฅ:
getpop/api
getpop/api-clients
getpop/api-endpoints
getpop/api-endpoints-for-wp
getpop/api-graphql
getpop/api-mirrorquery
GraphQL ์๋ฒ ๊ธฐ๋ฅ:
graphql-by-pop/graphql-clients-for-wp
graphql-by-pop/graphql-endpoint-for-wp
graphql-by-pop/graphql-parser
graphql-by-pop/graphql-query
graphql-by-pop/graphql-request
graphql-by-pop/graphql-server
๋ฐ์ดํฐ ๋ชจ๋ธ:
pop-schema/basic-directives
pop-schema/categories
pop-schema/categories-wp
pop-schema/comment-mutations
pop-schema/comment-mutations-wp
pop-schema/commentmeta
pop-schema/commentmeta-wp
pop-schema/comments
pop-schema/comments-wp
pop-schema/custompost-mutations
pop-schema/custompost-mutations-wp
pop-schema/custompostmedia
pop-schema/custompostmedia-mutations
pop-schema/custompostmedia-mutations-wp
pop-schema/custompostmedia-wp
pop-schema/custompostmeta
pop-schema/custompostmeta-wp
pop-schema/customposts
pop-schema/customposts-wp
pop-schema/generic-customposts
pop-schema/media
pop-schema/media-wp
pop-schema/menus
pop-schema/menus-wp
pop-schema/meta
pop-schema/metaquery
pop-schema/metaquery-wp
pop-schema/pages
pop-schema/pages-wp
pop-schema/post-categories
pop-schema/post-categories-wp
pop-schema/post-mutations
pop-schema/post-tags
pop-schema/post-tags-wp
pop-schema/posts
pop-schema/posts-wp
pop-schema/queriedobject
pop-schema/queriedobject-wp
pop-schema/schema-commons
pop-schema/tags
pop-schema/tags-wp
pop-schema/taxonomies
pop-schema/taxonomies-wp
pop-schema/taxonomymeta
pop-schema/taxonomymeta-wp
pop-schema/taxonomyquery
pop-schema/taxonomyquery-wp
pop-schema/user-roles
pop-schema/user-roles-access-control
pop-schema/user-roles-wp
pop-schema/user-state
pop-schema/user-state-access-control
pop-schema/user-state-mutations
pop-schema/user-state-mutations-wp
pop-schema/user-state-wp
pop-schema/usermeta
pop-schema/usermeta-wp
pop-schema/users
pop-schema/users-wp