⭐️ Released v2.6 with new MultilingualPress extension (for multilingual sites)
Gato GraphQL v2.6
has been released, containing several new features. Check out the release notes in GitHub for the complete list of changes.
Below are the most important additions.
[PRO] Added integration with MultilingualPress
Gato GraphQL PRO now has an integration with the MultilingualPress plugin.
With the new MultilingualPress extension, the GraphQL schema is provided the fields to retrieve multilingual data.
For instance, you can now run this query:
query {
posts {
multilingualpressTranslationConnections {
...MultilingualPressConnectionData
}
categories {
multilingualpressTranslationConnections {
...MultilingualPressConnectionData
}
}
tags {
multilingualpressTranslationConnections {
...MultilingualPressConnectionData
}
}
}
pages {
multilingualpressTranslationConnections {
...MultilingualPressConnectionData
}
}
customPosts(filter: { customPostTypes: "some-cpt" }) {
__typename
...on GenericCustomPost {
multilingualpressIsTranslatable
multilingualpressTranslationConnections {
...MultilingualPressConnectionData
}
categories(taxonomy: "some-category") {
__typename
...on GenericCategory {
multilingualpressIsTranslatable
multilingualpressTranslationConnections {
...MultilingualPressConnectionData
}
}
}
tags(taxonomy: "some-tag") {
__typename
...on GenericTag {
multilingualpressIsTranslatable
multilingualpressTranslationConnections {
...MultilingualPressConnectionData
}
}
}
}
}
}
fragment MultilingualPressConnectionData {
siteID
entityID
}
With this addition, we can use Gato GraphQL to automatically translate posts for the MultilingualPress plugin, and store those translations in the corresponding sites in the WordPress multisite network.
Check the video for demo Automatically translating posts for MultilingualPress (on a WordPress multisite network) to see how it works:
_strRegexFindMatches
[PRO] Added field
The _strRegexFindMatches
field has been added to the GraphQL schema (under the PHP Functions via Schema extension).
This field executes a regular expression to extract all matches from a string. For instance, running this query:
query {
_strRegexFindMatches(
regex: "/https?:\\/\\/([a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\\.[a-zA-Z]{2,})/",
string: "In website https://gatographql.com there is more information"
)
}
...will produce:
{
"data": {
"_strRegexFindMatches": [
[
"https:\/\/gatographql.com"
],
[
"gatographql.com"
]
]
}
}
With this addition, we can use Gato GraphQL to extract the empty strings from a Poedit file, translate them to any language, and create the corresponding Poedit file for that language.
Check the video for demo Translating all strings in a Poedit file for any language to see how it works:
siteURL
field Added
Added the following field to the GraphQL schema, via the "Site" module:
Root.siteURL
For instance, executing the following query:
query {
siteURL
}
...will produce:
{
"data": {
"siteURL": "https://mysite.com"
}
}
Added fields to fetch multisite data
The GraphQL schema now supports fetching data from a WordPress multisite network, provided via the new "Multisite" module.
This module adds the following fields to the GraphQL schema:
Root.networkSites
Root.networkSiteCount
Field networkSites
returns an array with all the sites in the network, each of the new NetworkSite
type, which contains the following fields:
id
name
url
locale
language
These fields are only enabled when multisite is enabled (i.e. when method is_multisite()
returns true
).
For instance, executing the following query:
query {
networkSiteCount
networkSites {
id
name
url
locale
language
}
}
might return:
{
"data": {
"networkSiteCount": 3,
"networkSites": [
{
"id": 1,
"name": "Site in English",
"url": "https://mymultisite.com",
"locale": "en_US",
"language": "en"
},
{
"id": 2,
"name": "Site in Spanish",
"url": "https://es.mymultisite.com",
"locale": "es_AR",
"language": "es"
},
{
"id": 3,
"name": "Site in French",
"url": "https://fr.mymultisite.com",
"locale": "fr_FR",
"language": "fr"
}
]
}
}
Added predefined persisted queries
The following persisted queries have been added to Gato GraphQL:
- [PRO] Translate posts for MultilingualPress (Gutenberg)
- [PRO] Translate posts for MultilingualPress (Classic editor)
- [PRO] Translate Poedit file content
[PRO] Added automation rules
The following automation rules have been added to Gato GraphQL PRO:
- MultilingualPress: When publishing a post, translate it to all languages (Gutenberg)
- MultilingualPress: When publishing a post, translate it to all languages (Classic editor)