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

Querying ACF/Option fields via GraphQL - Set language?

Open chrschick opened this issue 4 years ago • 2 comments

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.

chrschick avatar Feb 11 '21 07:02 chrschick

What do you mean with "custom endpoint"?

esamattis avatar Feb 15 '21 09:02 esamattis

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.

simplenotezy avatar Apr 22 '21 15:04 simplenotezy