Open jasonbahl opened 10 months ago
Steps to reproduce:
functions.php
:
acf_add_options_page(array(
'page_title' => __('Test Options'),
'menu_title' => __('Test Options'),
'show_in_graphql' => true,
'graphql_field_name' => 'testOptionsPage',
));
/**
* If external code has filtered this to return anything other than null, use the filtered type instead of the default
*
* @param mixed $null Filtered value. If filtered to anything other than null, use the filter response instead of the default logic below
* @param mixed $root The value of the previously resolved field in the tree
* @param array $args The arguments input on the field
* @param \WPGraphQL\AppContext $context The Context passed through resolution
* @param \GraphQL\Type\Definition\ResolveInfo $info Information about the field resolving
* @param \WPGraphQL\Acf\AcfGraphQLFieldType $field_type The Type of ACF Field resolving
* @param \WPGraphQL\Acf\FieldConfig $field_config The Config of the ACF Field resolving
* @param array $acf_field The ACF Field config
*/
function test_field_type_resolver($null, $root, $args, $context, $info, $field_type, $field_config, $acf_field) {
error_log('----------------------------------');
error_log('wpgraphql/acf/field_type_resolver');
error_log($acf_field['name']);
error_log($acf_field['type']);
return $null;
}
add_filter('wpgraphql/acf/field_type_resolver', 'test_field_type_resolver', 10, 8);
/**
* Filter the field value before resolving.
*
* @param mixed $value The value of the ACF Field stored on the node
* @param mixed $node The object the field is connected to
* @param mixed|string|int $node_id The ACF ID of the node to resolve the field with
* @param array $acf_field The ACF Field config
* @param bool $format Whether to apply formatting to the field
* @param string $field_key The key of the field being resolved
*/
function test_pre_resolve_acf_field($null, $root, $node_id, $field_config, $should_format_value, $field_key) {
error_log('----------------------------------');
error_log('wpgraphql/acf/pre_resolve_acf_field');
error_log($field_config['name']);
error_log($field_config['type']);
return $null;
}
add_filter('wpgraphql/acf/pre_resolve_acf_field', 'test_pre_resolve_acf_field', 10, 6);
/**
* Filter the value before returning
*
* @param mixed $value
* @param array $field_config The ACF Field Config for the field being resolved
* @param mixed $root The Root node or object of the field being resolved
* @param mixed $node_id The ID of the node being resolved
*/
function test_field_value($prepared_value, $field_config, $root, $node_id) {
error_log('----------------------------------');
error_log('wpgraphql/acf/field_value');
error_log($field_config['name']);
error_log($field_config['type']);
error_log(print_r($prepared_value, true));
return $prepared_value;
}
add_filter('wpgraphql/acf/field_value', 'test_field_value', 10, 4);
/wp-admin/admin.php?page=acf-options-test-options
and add a Banner to the flexible layout field.query Test {
testOptionsPage {
pageComponents {
pageComponents {
... on PageComponentsPageComponentsBannerLayout {
aSelectField
aTextField
}
}
}
}
}
[11-Jan-2024 00:31:46 UTC] ----------------------------------
[11-Jan-2024 00:31:46 UTC] wpgraphql/acf/field_type_resolver
[11-Jan-2024 00:31:46 UTC] page_components
[11-Jan-2024 00:31:46 UTC] flexible_content
[11-Jan-2024 00:31:46 UTC] ----------------------------------
[11-Jan-2024 00:31:46 UTC] wpgraphql/acf/pre_resolve_acf_field
[11-Jan-2024 00:31:46 UTC] page_components
[11-Jan-2024 00:31:46 UTC] flexible_content
[11-Jan-2024 00:31:46 UTC] ----------------------------------
[11-Jan-2024 00:31:46 UTC] wpgraphql/acf/field_value
[11-Jan-2024 00:31:46 UTC] page_components
[11-Jan-2024 00:31:46 UTC] flexible_content
[11-Jan-2024 00:31:46 UTC] Array
(
[0] => Array
(
[acf_fc_layout] => banner
[a_select_field] => option_a
[a_text_field] => Some Text
)
)
[11-Jan-2024 00:31:46 UTC] ---------------------------------- [11-Jan-2024 00:31:46 UTC] wpgraphql/acf/field_type_resolver [11-Jan-2024 00:31:46 UTC] a_text_field [11-Jan-2024 00:31:46 UTC] text
Notably:
1. `wpgraphql/acf/field_type_resolver` picks up the text field while the other 2 hooks do not.
2. None of the hooks pick up the select field.
@DevMude Thanks for the comprehensive steps to reproduce. This will help us with debugging and finding a proper resolution.
Thanks! 🙏
Description
related: #104 (see: https://github.com/wp-graphql/wpgraphql-acf/issues/104#issuecomment-1884257789)
It's been reported that the following filters are not working as expected:
wpgraphql/acf/field_type_resolver
wpgraphql/acf/pre_resolve_acf_field
wpgraphql/acf/field_value
Context: When trying to query a select field within a flexible layout or clone field. It only lets you filter on the value of the the top level clone field or flexible layout, not the fields nested inside those fields.
Steps to reproduce
Try and filter using one of the following filters:
wpgraphql/acf/field_type_resolver
wpgraphql/acf/pre_resolve_acf_field
wpgraphql/acf/field_value
PHP or JSON export of the ACF Field Group(s)
No response
Additional context
No response
WPGraphQL Version
1.19.0
WPGraphQL For ACF Version
2.0.0
ACF (Advanced Custom Fields) Version. Free or Pro?
PRO
WordPress Version
6.4.2
PHP Version
8.2
Additional enviornment details
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL, WPGraphQL For ACF, ACF, etc.