wp-graphql icon indicating copy to clipboard operation
wp-graphql copied to clipboard

bug: fetching translated posts by uri

Open moonmeister opened this issue 4 years ago • 2 comments

I'm seeing an issue with Polylang and trying to fetch content by uri. https://github.com/valu-digital/wp-graphql-polylang/issues/57 it's already been reported on the polylang repo but it may be a core issue. If I have 3 pages with the slug "about" but each in a different language, then only the english one is returned (english being the default language). I'm guessing this is a corner case that wasn't considered. Polylang uses the post_link hook to modify urls for rendering.

Can we confirm whether this is a polylang or graphql issue?

Versions

WordPress - 5.8 WPGraphQL - 1.62 Polylang Pro - 3.1-rc1 Polylang WPGraphQL - 0.5.0

moonmeister avatar Aug 09 '21 21:08 moonmeister

@moonmeister I can confirm I have the same issue. It seems like Polylang does not respect the "locale/" parameter in the URI.

E.g.

en/about-us --> english page, about us
de/about-us --> english page, about us (should have been the german page)
de/german-about-us --> german page, about us - only if slug is not taken in another language

simplenotezy avatar Jan 13 '22 19:01 simplenotezy

The issue is indeed with Polylang (tracking: https://github.com/valu-digital/wp-graphql-polylang/issues/35).

Currently, this can be handled by either graphql_pre_resolve_uri or request (h/t @simplenotezy ), but we should keep this (and other extensibility use cases) in mind if/when NodeResolver.php gets refactored.

justlevine avatar Apr 01 '22 19:04 justlevine