简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM