๐ Gato GraphQL v1.2 ์ถ์ (์๋ก์ด Persisted Queries ํ์ฌ)
Gato GraphQL ๋ฒ์ 1.2๊ฐ ์ถ์๋์์ต๋๋ค! ๐
๋ชจ๋ ๋ณ๊ฒฝ ์ฌํญ์ ๋ํ ์ค๋ช ์ ํ์ธํ์ธ์.
์ฌ๋ฌ ์ฌ์ ์ ์๋ Persisted Queries ์ถ๊ฐ
์ผ๋ฐ์ ์ธ ๊ด๋ฆฌ ์์ ์ ์คํํ๊ธฐ ์ํ ๋ค์ Persisted Queries๊ฐ ์ ๊ณต๋ฉ๋๋ค:
URL์์ ์ฝํ ์ธ ๋ฒ์ญ
URL์ ์ ๋ ฅ์ผ๋ก ๋ฐ์ ํด๋น ์ธ์ด์ ๋ฒ์ญํ ์ธ์ด๋ฅผ ์ง์ ํ๋ฉด, ์ด ์ฟผ๋ฆฌ๋ URL์์ ์ฝํ ์ธ ๋ฅผ ๊ฐ์ ธ์ Google Translate๋ฅผ ์ฌ์ฉํ์ฌ ๋ฒ์ญ์ ์คํํฉ๋๋ค:
query TranslateContent(
$url: URL!
$fromLang: String!
$toLang: String!
) {
_sendHTTPRequest(input: {
url: $url,
method: GET
}) {
body
translated: body @strTranslate(
from: $fromLang
to: $toLang
)
}
}์๋ฅผ ๋ค์ด, GitHub ์ ์ฅ์์ Markdown ํ์ผ URL๊ณผ ์ธ์ด ์ฝ๋ "es"๋ฅผ ์ ๋ฌํ๋ฉด:
{
"url": "https://raw.githubusercontent.com/GatoGraphQL/GatoGraphQL/c870d8906ae1aec3c81acc039c53acc7aab5dff0/layers/GatoGraphQLForWP/plugins/gatographql/docs/modules/single-endpoint/en.md",
"fromLang": "en",
"toLang": "es"
}...Markdown ์ฝํ ์ธ ๊ฐ ์คํ์ธ์ด๋ก ๋ฒ์ญ๋ฉ๋๋ค:
{
"data": {
"_sendHTTPRequest": {
"body": "# Single Endpoint\n\nExecute queries against the GraphQL server through the public single endpoint.\n\nBy default the endpoint is `/graphql/`, and the path can be configured through the Settings.\n\n\n\nThe GraphQL single endpoint can be configured by assigning a Schema Configuration to it. To do this, on section \"Schema Configuration\" select the desired entry from the dropdown for \"Schema Configuration for the Single Endpoint\":\n\n<div class=\"img-width-1024\" markdown="1">\n\n\n\n</div>\n\n## Clients\n\nInteract with the single endpoint via the available clients.\n\n### GraphiQL\n\nIf module \"GraphiQL for Single Endpoint\" is enabled, then the single endpoint's GraphiQL client becomes publicly available.\n\nTo open it, click on link \"๐ข GraphiQL (public)\" on the plugin's menu:\n\n<div class=\"img-width-1024\" markdown="1">\n\n\n\n</div>\n\nBy default, the client is exposed under `/graphiql/`. This path can be modified on the Settings, under tab \"GraphiQL for Single Endpoint\":\n\n<div class=\"img-width-1024\" markdown="1">\n\n\n\n</div>\n\n### Interactive Schema (Voyager)\n\nIf module \"Interactive Schema for Single Endpoint\" is enabled, then the single endpoint's Voyager client becomes publicly available.\n\nTo open it, click on link \"๐ข Schema (public)\" on the plugin's menu:\n\n<div class=\"img-width-1024\" markdown="1">\n\n\n\n</div>\n\nBy default, the client is exposed under `/schema/`. This path can be modified on the Settings, under tab \"Interactive Schema for Single Endpoint\":\n\n<div class=\"img-width-1024\" markdown="1">\n\n\n\n</div>\n",
"translated": "# Punto final รบnico\n\nEjecute consultas en el servidor GraphQL a travรฉs del punto final รบnico pรบblico.\n\nDe forma predeterminada, el punto final es `/graphql/` y la ruta se puede configurar a travรฉs de Configuraciรณn.\n\n\n\nEl punto final รบnico GraphQL se puede configurar asignรกndole una configuraciรณn de esquema. Para hacer esto, en la secciรณn \"Configuraciรณn del esquema\", seleccione la entrada deseada del menรบ desplegable para \"Configuraciรณn del esquema para el punto final รบnico\":\n\n<div class=\"img-width-1024\" descuento=1>\n\n\n\n</div>\n\n## Clientes\n\nInteractรบe con el punto final รบnico a travรฉs de los clientes disponibles.\n\n### GrafiQL\n\nSi el mรณdulo \"GraphiQL para punto final รบnico\" estรก habilitado, el cliente GraphiQL del punto final รบnico estarรก disponible pรบblicamente.\n\nPara abrirlo, haga clic en el enlace \"๐ข GraphiQL (pรบblico)\" en el menรบ del complemento:\n\n<div class=\"img-width-1024\" descuento=1>\n\n\n\n</div>\n\nDe forma predeterminada, el cliente estรก expuesto en `/graphiql/`. Esta ruta se puede modificar en Configuraciรณn, en la pestaรฑa \"GraphiQL para punto final รบnico\":\n\n<div class=\"img-width-1024\" descuento=1>\n\n\n\n</div>\n\n### Esquema interactivo (Voyager)\n\nSi el mรณdulo \"Esquema interactivo para punto final รบnico\" estรก habilitado, el cliente Voyager del punto final รบnico estarรก disponible pรบblicamente.\n\nPara abrirlo, haga clic en el enlace \"๐ข Esquema (pรบblico)\" en el menรบ del complemento:\n\n<div class=\"img-width-1024\" descuento=1>\n\n\n\n</div>\n\nDe forma predeterminada, el cliente estรก expuesto en `/schema/`. Esta ruta se puede modificar en Configuraciรณn, en la pestaรฑa \"Esquema interactivo para punto final รบnico\":\n\n<div class=\"img-width-1024\" descuento=1>\n\n\n\n</div>\n"
}
}
}์ด ๋ด์ฉ์ Recipes ์น์ ์ "Translating content from URL"์๋ ์ถ๊ฐ๋์์ต๋๋ค.
๊ฒ์๋ฌผ ๋ฒ์ญ (ํด๋์ ์๋ํฐ) ๋ฐ ๊ฒ์๋ฌผ ์ผ๊ด ๋ฒ์ญ (ํด๋์ ์๋ํฐ)
์ด๋ฏธ "Translate post"์ "Translate posts"(์ผ๊ด) Persisted Queries๊ฐ ์กด์ฌํ์ผ๋ฉฐ, ์ด๋ ๊ฒ์๋ฌผ ๋ด Gutenberg ๋ธ๋ก์ ๋ชจ๋ ์์ฑ์ ๋ฒ์ญํ๋ ๊ฒ์ด์์ต๋๋ค.
์ด๋ค์ "Translate post (Gutenberg)"์ "Translate posts (Gutenberg)"๋ก ์ ์ ํ ์ด๋ฆ์ด ๋ณ๊ฒฝ๋์๊ณ , ํด๋์ ์๋ํฐ์ฉ ์ฝํ ์ธ ๋ฅผ ๋ฒ์ญํ๋ ์๋ก์ด Persisted Queries๊ฐ ์ถ๊ฐ๋์์ต๋๋ค:
- Translate post (Classic editor): ๋จ์ผ ๊ฒ์๋ฌผ ๋ฒ์ญ
- Translate posts (Classic editor): ์ฌ๋ฌ ๊ฒ์๋ฌผ ์ผ๊ด ๋ฒ์ญ
์ด ๋ชจ๋ ์ฟผ๋ฆฌ๋ Google Translate API๋ฅผ ํธ์ถํ์ฌ ์ฝํ ์ธ ๋ฅผ ๋ฒ์ญํ๋ฉฐ, ๋จ์ผ ์์ฒญ์ผ๋ก ๋ชจ๋ ๋ฐ์ดํฐ๋ฅผ ์ ์กํฉ๋๋ค.
์๋ฅผ ๋ค์ด, "Translate posts (Classic editor)" ์ฟผ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ 5๊ฐ์ ๊ฒ์๋ฌผ์ ๋ฒ์ญํ ๊ฒฝ์ฐ, 5๊ฐ ๊ฒ์๋ฌผ ๋ชจ๋์ ๋ฐ์ดํฐ(์ ๋ชฉ, ๋ณธ๋ฌธ, ๋ฐ์ท๋ฌธ)๊ฐ ํ๊บผ๋ฒ์ ์ ์ก๋๋ฏ๋ก ํ๋ถํ ์ปจํ ์คํธ๊ฐ ์ ๊ณต๋์ด ๋ฒ์ญ ์ ํ๋๊ฐ ๋์์ง๋๋ค.
์๋ฅผ ๋ค์ด, ์ด ๊ฒ์๋ฌผ์ ์์ด์์ ์ค๊ตญ์ด๋ก ๋ฒ์ญํ๋ฉด:

...๋ค์๊ณผ ๊ฐ์ด ๋ณํ๋ฉ๋๋ค:

WordPress RSS ํผ๋์์ ๊ฒ์๋ฌผ ๊ฐ์ ธ์ค๊ธฐ
๊ฒ์๋ฌผ์ WordPress RSS ํผ๋๋ฅผ ์ง์ ํ๋ฉด ํด๋น ๋ฐ์ดํฐ๋ก ์ ๊ฒ์๋ฌผ์ด ์์ฑ๋ฉ๋๋ค.
์๋ฅผ ๋ค์ด, ์ด ์ฟผ๋ฆฌ๋ ๋จ์ผ ๊ฒ์๋ฌผ์ ๋ค์ RSS ํผ๋๋ฅผ ํ์ฑํฉ๋๋ค(์ผ๋ฐ์ ์ผ๋ก https://mysite.com/post-slug/feed/rss/?withoutcomments=1์์ ์ ๊ทผ ๊ฐ๋ฅํฉ๋๋ค):
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title>A tale of two cities – teaser – PoP API Demo</title>
<atom:link href="https://mysite.com/blogroll/a-tale-of-two-cities-teaser/feed/?withoutcomments=1" rel="self" type="application/rss+xml" />
<link>https://mysite.com</link>
<description>Just another WordPress site</description>
<lastBuildDate>Tue, 20 Jul 2021 23:03:59 +0000</lastBuildDate>
<language>en-US</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1 </sy:updateFrequency>
<generator>https://wordpress.org/?v=6.1.1</generator>
<item>
<title>A tale of two cities – teaser</title>
<link>https://mysite.com/blogroll/a-tale-of-two-cities-teaser/</link>
<comments>https://mysite.com/blogroll/a-tale-of-two-cities-teaser/#comments</guides/query/comments>
<dc:creator>leo</dc:creator>
<pubDate>Mon, 21 Dec 2020 08:24:18 +0000</pubDate>
<category>Blogroll</category>
<category>championship</category>
<category>book</category>
<guid isPermaLink="false">https://mysite.com/?p=1657</guid>
<description></description>
<content:encoded>
<p>It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other wayโin short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.</p>
</content:encoded>
<wfw:commentRss>https://mysite.com/blogroll/a-tale-of-two-cities-teaser/feed/</wfw:commentRss>
<slash:comments>45</slash:comments>
</item>
</channel>
</rss>CSV์์ ๊ฒ์๋ฌผ ๊ฐ์ ธ์ค๊ธฐ
CSV๋ฅผ ์ ๊ณตํ๋ฉด ๊ฐ ํญ๋ชฉ(์ ๋ชฉ, ๋ฐ์ท๋ฌธ, ๋ณธ๋ฌธ, ์์ฑ์)์ ํด๋นํ๋ ๋ฐ์ดํฐ๋ก ๊ฒ์๋ฌผ์ด ์์ฑ๋ฉ๋๋ค.
์๋ฅผ ๋ค์ด, ์๋ CSV๋ 3๊ฐ์ ๊ฒ์๋ฌผ์ ์์ฑํฉ๋๋ค:
Title,Excerpt,Content,Author
Multi-channelled optimal interface,Inventore iste velit et expedita ipsa dolor,"<!-- wp:paragraph -->
<p>Inventore iste velit et expedita ipsa dolor. Optio suscipit qui id harum corporis dignissimos.</p>
<!-- /wp:paragraph -->",admin
Ergonomic motivating parallelism,Consequuntur velit quasi assumenda,"<!-- wp:paragraph -->
<p>Consequuntur velit quasi assumenda. Eum non saepe est. Ut dolorem harum eveniet eaque nemo impedit. Voluptatem commodi modi sed sed animi voluptatem.</p>
<!-- /wp:paragraph -->
<!-- wp:image {""id"":5,""sizeSlug"":""large""} -->
<figure class=""wp-block-image size-large""><img src=""https://mysite.com/wp-content/uploads/2023/09/wordpress0.jpg"" alt="""" class=""wp-image-5""/></figure>
<!-- /wp:image -->
<!-- wp:image {""id"":7,""sizeSlug"":""large""} -->
<figure class=""wp-block-image size-large""><img src=""https://mysite.com/wp-content/uploads/2023/09/wordpress2.jpg"" alt="""" class=""wp-image-7""/></figure>
<!-- /wp:image -->",admin
Down-sized solution-oriented securedline,Ipsam minima qui asperiores dolorum unde voluptas quia voluptate,"<!-- wp:paragraph -->
<p>Ipsam minima qui asperiores dolorum unde voluptas quia voluptate. Incidunt omnis cumque beatae quo deleniti ex. Praesentium nihil et consectetur neque commodi tempora ipsa adipisci. Praesentium perferendis sint est.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>Et aut fuga aliquam consequuntur dolore sunt ut ut. Quibusdam in voluptas vitae quia eaque. Eligendi dolorum dolorem vitae et vitae et ut.</p>
<!-- /wp:paragraph -->",admin
์ฟผ๋ฆฌ๋ฅผ ์คํํ๋ฉด ๋ค์ ๊ฒฐ๊ณผ๊ฐ ๋ํ๋ฉ๋๋ค:

๊ฒ์๋ฌผ ๋งํฌ ๊ฐ์ ธ์ค๊ธฐ
๋ชจ๋ ๊ฒ์๋ฌผ์ ๋ชจ๋ ๋งํฌ๋ฅผ ๊ฒ์ํ์ฌ(๋ชจ๋ <a href="(...)">(...)</a> ๋ฌธ์์ด์ ๊ฒ์), { href: (...), text: (...) } ์์ฑ์ ๊ฐ์ง JSON ๊ฐ์ฒด๋ก ์๋ต์ ๋ชฉ๋กํํฉ๋๋ค.
์๋ฅผ ๋ค์ด, ๋ค์๊ณผ ๊ฐ์ ์๋ต์ด ๋ฐํ๋ ์ ์์ต๋๋ค:
{
"data": {
"posts": [
{
"id": 1435,
"title": "Citations from famous authors",
"links": [
{
"href": "https://www.azquotes.com/author/4085-Fyodor_Dostoevsky",
"text": "Quote by Fyodor Dostoevsky"
},
{
"href": "https://www.azquotes.com/author/14706-Leo_Tolstoy",
"text": "Quote by Leon Tolstoi"
},
{
"href": "https://www.azquotes.com/author/15138-Voltaire",
"text": "Quote by Voltaire"
}
]
},
{
"id": 1,
"title": "Hello world!",
"links": []
}
]
}
}XML ์ค์นผ๋ผ ํ์
์ถ๊ฐ
์๋ก์ด XML ์ค์นผ๋ผ ํ์
์ ํตํด XML ๋ฌธ์์ด์ ์
๋ ฅํ ์ ์๊ฒ ๋์์ต๋๋ค. ์ด ์ค์นผ๋ผ ํ์
์ XML ๋ฌธ์์ด์ ์ ํ์ฑ์ ๊ฒ์ฆํฉ๋๋ค.
์๋ฅผ ๋ค์ด, ์ด ์ฟผ๋ฆฌ:
{
_strDecodeXMLAsJSON(xml: """<?xml version="1.0" encoding="UTF-8"?>
<body>
<message>Hello world!</message>
</body>
""")
}...๋ ๋ค์ ๊ฒฐ๊ณผ๋ฅผ ์์ฑํฉ๋๋ค:
{
"data": {
"_strDecodeXMLAsJSON": {
"message": "Hello world!"
}
}
}๋ฐ๋ฉด, ์ด ์ฟผ๋ฆฌ:
{
_strDecodeXMLAsJSON(xml: """<?xml version="1.0" encoding="UTF-8"?>
<body>
<message>Hello world!</message>
""")
}...๋ ๋ค์ ๊ฒฐ๊ณผ๋ฅผ ์์ฑํฉ๋๋ค:
{
"errors": [
{
"message": "Cannot cast value '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <body>\n <message>Hello world!<\/message>\n ' for type 'XML'",
"locations": [
{
"line": 2,
"column": 31
}
],
"extensions": {
"field": "_strDecodeXMLAsJSON(xml: \"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <body>\n <message>Hello world!<\/message>\n \")",
"problems": [
"Premature end of data in tag body line 2\n"
]
}
}
],
"data": {
"_strDecodeXMLAsJSON": null
}
}๋ฌธ์ ๊ฐ์
- Helper Function Collection ์ต์คํ
์
์ ์๋ก์ด ํ๋์ ๋ํ ๋ฌธ์ ์ถ๊ฐ:
_strDecodeXMLAsJSON_strParseCSV
์์ ์ฌํญ
- ์ฌ์ ์ ์๋ Persisted Queries "Translate post"์ "Translate posts"์์ ๋ธ๋ก์
attributes.{something}์์ฑ์ ์ ํํ ๋failIfNonExistingKeyOrPath: false๋ฅผ ์ถ๊ฐ(์ ์๋์ง ์์ ์ ์๊ธฐ ๋๋ฌธ) - ์ฌ์ ์ ์๋ Persisted Query "Import post from WordPress site"์์ ๊ฒ์๋ฌผ์ ์ ํํ๊ธฐ ์ํด ์ํ
any๋ฅผ ์ถ๊ฐ - Persisted Query "Translate post"๋ฅผ "Translate post (Gutenberg)"๋ก, "Translate posts"๋ฅผ "Translate posts (Gutenberg)"๋ก ์ด๋ฆ ๋ณ๊ฒฝ