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

Language field do not exist in ACF options

Open robert-orlinski opened this issue 3 years ago • 11 comments

Hi, I am trying to get access to the "language" field while querying ACF option fields but I am not able to do so - there is no such field and as a result, there is no way to do a query like this:

siteSettings(language: EN) {
    siteSettings {
        footerTitle
    }
}

I have the plugin installed in WordPress, along with ACF Options for Polylang, Advanced Custom Fields PRO, WP Gatsby, WP GraphQL, WP GraphQL Polylang, WPGraphQL Custom Post Type UI, WPGraphQL for Advanced Custom Fields - uninstalling singular and checking if the problem disappears does not work and that's the reason I am asking here.

From the Gatsby side, I was using both gatsby-source-wordpress and gatsby-source-graphql, and no one is showing anything like "languages" filter.

Thank you in advance for any help!

robert-orlinski avatar Jul 05 '21 17:07 robert-orlinski

Same here :/ I hope that the developer can fix it

BenjaminZekavica avatar Jul 17 '21 11:07 BenjaminZekavica

Same here.

sven-ra avatar Dec 13 '21 10:12 sven-ra

Facing the same issue. I hope it get fixed soon otherwise another option is to go with WPML.

salmanamemon avatar Dec 20 '21 05:12 salmanamemon

Same here. On two projects it became necessary to use. Looks like I'll have to change the plugin to WPML

8simsim8 avatar Jan 10 '22 17:01 8simsim8

Any Updates?

sidyes avatar Jan 16 '22 13:01 sidyes

The plugin emits a warning if there is no explicit graphql_field_name on an options page and skips adding a language argument. My workaround was to add this filter:

use WPGraphQL\Utils\Utils;

/**
 * Makes sure that an explicit graphql_field_name name is set for each ACF
 * options page, because wp-graphql-polylang won’t add language support to it
 * otherwise.
 */
add_filter("acf/validate_options_page", function ($page) {
  if (!empty($page["show_in_graphql"]) && empty($page["graphql_field_name"])) {
    $type_name = Utils::format_type_name($page["menu_slug"]);
    $page["graphql_field_name"] = Utils::format_field_name($type_name);
  }
  return $page;
});

jeanfredrik avatar Mar 01 '22 12:03 jeanfredrik

@esamattis Any update on this?

brianpereradap avatar Jun 01 '22 14:06 brianpereradap

The plugin emits a warning if there is no explicit graphql_field_name on an options page and skips adding a language argument. My workaround was to add this filter:

use WPGraphQL\Utils\Utils;

/**
 * Makes sure that an explicit graphql_field_name name is set for each ACF
 * options page, because wp-graphql-polylang won’t add language support to it
 * otherwise.
 */
add_filter("acf/validate_options_page", function ($page) {
  if (!empty($page["show_in_graphql"]) && empty($page["graphql_field_name"])) {
    $type_name = Utils::format_type_name($page["menu_slug"]);
    $page["graphql_field_name"] = Utils::format_field_name($type_name);
  }
  return $page;
});

This workaround worked for me. Thanks.

brianpereradap avatar Jun 01 '22 15:06 brianpereradap