⭐️ Released v4.1 with data-filtering by language for Polylang (PRO)

Leonardo Losoviz
By Leonardo Losoviz ·

Gato GraphQL v4.1 has been released. Check out the release notes in GitHub for the complete list of changes.

The most important new feature belongs to Gato GraphQL PRO.

[PRO] Polylang: Filter data by language

With the Polylang extension, we can now filter data by language.

We can provide the language to filter by when fetching data for:

  • Posts
  • Pages
  • Custom posts
  • Categories
  • Tags
  • Media items

The corresponding fields receive input polylangLanguage, and we can filter by code or locale, and by 1 or more than 1 language.

For instance, passing $languageCodes: ["es"] will fetch data in Spanish:

query FilterByLanguage($languageCodes: [String!])
{
  posts(filter: {
    polylangLanguages: { codes: $languageCodes }
  }) {
    id
    title
  }
 
  pages(filter: {
    polylangLanguages: { codes: $languageCodes }
  }) {
    id
    title
  }
 
  customPosts(filter: {
    customPostTypes: ["some-cpt"]
    polylangLanguages: { codes: $languageCodes }
  }) {
    id
    title
  }
 
  postCategories(filter: {
    polylangLanguages: { codes: $languageCodes }
  }) {
    id
    name
  }
 
  postTags(filter: {
    polylangLanguages: { codes: $languageCodes }
  }) {
    id
    name
  }
 
  categories(
    taxonomy: "some-category"
    filter: { polylangLanguages: { codes: $languageCodes } }
  ) {
    id
    name
  }
 
  tags(
    taxonomy: "some-tag"
    filter: { polylangLanguages: { codes: $languageCodes } }
  ) {
    id
    name
  }
 
  mediaItems(filter: {
    polylangLanguages: { codes: $languageCodes }
  }) {
    id
    title
  }
}

Want more posts & tutorials?

Receive timely updates as we keep improving Gato GraphQL.

No spam. You can unsubscribe at any time.