We can combine the fields to execute HTTP requests (provided by the HTTP Client extension) with directive @strTranslate
(provided by the **Google Translate ** extension), to translate the content from any URL.
This query, given a URL as input, its language, and what language to translate it to, fetches the content from the URL and performs the translation using Google Translate:
query TranslateContent (
$url : URL!
$fromLang : String!
$toLang : String!
) {
_sendHTTPRequest ( input : {
url : $url ,
method : GET
}) {
body
translated : body @strTranslate (
from : $fromLang
to : $toLang
)
}
}
Copy
For instance, passing the URL of some Markdown file in a GitHub repo , and language code "es"
:
{
"url" : "https://raw.githubusercontent.com/GatoGraphQL/GatoGraphQL/c870d8906ae1aec3c81acc039c53acc7aab5dff0/layers/GatoGraphQLForWP/plugins/gatographql/docs/modules/single-endpoint/en.md" ,
"fromLang" : "en" ,
"toLang" : "es"
}
Copy
...will translate the Markdown content to Spanish:
{
"data" : {
"_sendHTTPRequest" : {
"body" : "# Single Endpoint \n\n Execute queries against the GraphQL server through the public single endpoint. \n\n By default the endpoint is `/graphql/`, and the path can be configured through the Settings. \n\n ![Single endpoint in Settings](../../images/settings-single-endpoint.png \" Single endpoint in Settings \" ) \n\n The 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 ![Settings for the Schema Configuration for the Single Endpoint](../../images/settings-schema-configuration-for-single-endpoint.png) \n\n </div> \n\n ## Clients \n\n Interact with the single endpoint via the available clients. \n\n ### GraphiQL \n\n If module \" GraphiQL for Single Endpoint \" is enabled, then the single endpoint's GraphiQL client becomes publicly available. \n\n To open it, click on link \" 🟢 GraphiQL (public) \" on the plugin's menu: \n\n <div class= \" img-width-1024 \" markdown=" 1 "> \n\n ![Single endpoint's link to the GraphiQL client](../../images/single-endpoint-graphiql-link.png) \n\n </div> \n\n By 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 ![Path to GraphiQL client](../../images/settings-graphiql-for-single-endpoint.png) \n\n </div> \n\n ### Interactive Schema (Voyager) \n\n If module \" Interactive Schema for Single Endpoint \" is enabled, then the single endpoint's Voyager client becomes publicly available. \n\n To open it, click on link \" 🟢 Schema (public) \" on the plugin's menu: \n\n <div class= \" img-width-1024 \" markdown=" 1 "> \n\n ![Single endpoint's link to the Interactive Schema client](../../images/single-endpoint-interactive-schema-link.png) \n\n </div> \n\n By 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 ![Path to Voyager client](../../images/settings-interactive-schema-for-single-endpoint.png) \n\n </div> \n " ,
"translated" : "# Punto final único \n\n Ejecute consultas en el servidor GraphQL a través del punto final único público. \n\n De forma predeterminada, el punto final es `/graphql/` y la ruta se puede configurar a través de Configuración. \n\n ![Punto final único en Configuración](../../images/settings-single-endpoint.png \" Punto final único en Configuración \" ) \n\n El 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 ![Configuración del esquema para el punto final único](../../images/settings-schema-configuration-for-single-endpoint.png) \n\n </div> \n\n ## Clientes \n\n Interactúe con el punto final único a través de los clientes disponibles. \n\n ### GrafiQL \n\n Si el módulo \" GraphiQL para punto final único \" está habilitado, el cliente GraphiQL del punto final único estará disponible públicamente. \n\n Para 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 ![Enlace del punto final único al cliente GraphiQL](../../images/single-endpoint-graphiql-link.png) \n\n </div> \n\n De 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 ![Ruta al cliente GraphiQL](../../images/settings-graphiql-for-single-endpoint.png) \n\n </div> \n\n ### Esquema interactivo (Voyager) \n\n Si el módulo \" Esquema interactivo para punto final único \" está habilitado, el cliente Voyager del punto final único estará disponible públicamente. \n\n Para 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 ![Enlace del punto final único al cliente de esquema interactivo](../../images/single-endpoint-interactive-schema-link.png) \n\n </div> \n\n De 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 ![Ruta al cliente Voyager](../../images/settings-interactive-schema-for-single-endpoint.png) \n\n </div> \n "
}
}
}
Copy