Search code examples
wordpressgatsbypolylangwp-graphql

Querying with language filter in Gatsby GraphQL from Wordpress with polylang returns null


I work on a website that is build with Wordpress as a headless CMS and I connect it to Gatsby with WPGraphql. Everything worked fine until I tried to add polylang plugin in order to make it multilingual. I added a page with two languages and inside wp-admin graphql playground I was able to fetch pages based on a language.

I activated Polylang and WP GraphQL Polylang in my plugins page.

When I try to do the same in gatsby graphql playground it returns null, my query looks like this:

query MyQuery {
  allWpPage(filter: {language: {code: {eq: EN}}}) {
    nodes {
      slug
    }
  }
}

Should I configure something within Gatsby repository?


Solution

  • According to this GitHub thread, it seems to be needed the PRO version of Polylang.

    If that's your case, you can use the https://github.com/dannyvaughton/wp-rest-polylang-pro, a modified version that exposes the languages to WP Rest.

    Either way, it's not a Gatsby issue, but WordPress.