valu-digital / wp-graphql-polylang

WPGraphQL Polylang Extension for WordPress
https://packagist.org/packages/valu/wp-graphql-polylang
GNU General Public License v2.0
129 stars 22 forks source link

Get single page by language #66

Open simplenotezy opened 2 years ago

simplenotezy commented 2 years ago

I believe this repository is missing the ability to specifiy language when fetching a single page/post. E.g.:

query Pages {
  page(id: "some-slug", idType: URI, language: EN) {
ozcancelik commented 2 years ago

I solved single post language issue with translation. Example:

query getSinglePost {
    post(id: "lorem-ipsum", idType: SLUG) {
      translation(language: EN) {
        title
        content
        slug
      }
    }
  }

if you want to reach as variable use $language: LanguageCodeEnum! I hope it helps someone.

Triphys commented 4 weeks ago

if you want to reach as variable use $language: LanguageCodeEnum! I hope it helps someone.

Thank you, this made my day!