valu-digital / wp-graphql-polylang

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

Not able to get correct response with language on Option Pages #88

Open gmemeint opened 5 months ago

gmemeint commented 5 months ago

Hello,

I need help because I'm probably missing something, but I'm unable to get a proper reponse to retrieve multilingual Options pages correctly.

Context Headless Wordpress with NuxtJS front-office.

I have :

I create an Option pages like this:

acf_add_options_page([
    'page_title' => __('Site settings', 'theme'),
    'menu_title' => __('Site settings', 'theme'),
    'menu_slug' => 'site-settings',
    'post_id' => 'options',
    'capability' => 'manage_options',
    'redirect' => false,
    'show_in_graphql' => true,
    'graphql_field_name' => 'options'
  ]);

I have an ACF Field groups named "Options" that I have in 2 languages (FR / EN) Each of them is exposed to GraphQL with Field Name = "options" and show if Options Page = Site settings

I am able to contribute it when I switch my language in my top bar without any problem. I checked my database, and I see my fields with option_name :

So it seems that at this point, everything seems to work as expected.

But when I try to build my GraphQL request, I am able to see the language variable, the FR version (which is the default one) is returning the value correctly, but my EN version is always returning null. I tried to debug, but didn't find anything relevant yet.

I only saw this which seems weird (when using FR I do not see frFR concatened) : SELECT option_value FROM panzani_options WHERE option_name = '_optionsenGB_cookies_banner_title' LIMIT 1

I found a workaround but it is not what I want in my front, if I change for my Field groups EN the graphql name from "options" to "options_en", I am able to retrieve the correct value. But it means that I have two different GraphQL fields for the same purpose.

Thanks in advance if someone has some tips :)

PSMJonas commented 3 months ago

Same issue.

PSMJonas commented 3 months ago

Fixed it in #93.