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

Querying ACF/Option fields via GraphQL - Set language? #40

Open chrschick opened 3 years ago

chrschick commented 3 years ago

Hi,

It's more like a question but an issue.

We're using Polylang in combination with WPGraphQL Plugin and also ACF. When we're trying to query specific ACF Options field values via custom endpoints, we don't receive anything but NULL.

Is there any chance to set the language and get the correct data from option fields while resolving our request? I tried to set the language with some class functions delivered within the plugin.

PLL()->curlang = PLL()->model->get_language($args['language']);
echo pll_current_language();  // Returns the language set by the line above

Sadly this line doesn't work, it seems that the language isn't really set inside the context.

esamattis commented 3 years ago

What do you mean with "custom endpoint"?

simplenotezy commented 3 years ago

I believe this is related to my issue;

I am trying to register a GraphQL field (https://www.wpgraphql.com/2020/03/11/registering-graphql-fields-with-arguments/), and inside the resolve callback, I need to do a WP query, and for that I’d like to query posts in specific language. How can I get the current language? Unfortunately pll_current_language() returns false.