You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, seems like after some updates there is an issue with the field resolution for custom registered field like for example FontAwesomeIcon (code provided in steps to reproduce).
I am successfully using this field that I registered just a couple of weeks ago on pages and also on the options page in some previously registered fields. However, when I try to register a new field of this type, it suddenly returns null for item attributes in GraphQL. The value is set and visible in the WP Admin, properly stored in the database, and the field is correctly resolved in the filter graphql_resolve_field. When I hook into graphql_resolve_field and dump the $result value for this field, all data looks like the data I would expect to be returned by GraphQL. However, if the query is run, all object items contain a value of null. If the field does not have any value, null is returned as expected.
Probably worth mentioning that if I colocate this new field just next to the working icon that is part of the repeater socialIcons FontAwesome field on the options page, it returns proper data and not nulls. In example below iconFa is the new icon that does not work in previous example.
This looks like something similar that was happening here #128 , but I was not able to figure out what is going wrong between filters graphql_resolve_field where the correct value is resolved and graphql_request_results where the incorrect value is in the response and what plugin is responsible for introducing this strange behavior.
To discard all the nuances mentioned above and the intricacies related to the setup, I have set up a vanilla testing environment with only the necessary plugins enabled and updated to the latest versions. I am getting null values for the options page registered field as well as for the field registered on the page. Could anyone please have a look at what is going wrong between the field resolution and what is actually returned by the WPGraphQL plugin?
Steps to reproduce
Set up the environment with ACF Pro, WPGraphQL, Font Awesome for ACF, WPGraphQL ACF extensions
Register FontAwesomeIcon field type and object type
/** Register a Font Awesome icon GraphQL type to the shape that is coming from the ACF field * @see: https://www.wpgraphql.com/functions/register_graphql_object_type */add_action('graphql_register_types', function () {
register_graphql_object_type('FontAwesomeIcon', [
'description' => 'Represents a Font Awesome icon',
'fields' => [
'element' => [
'type' => 'String',
'description' => __('The HTML element for the icon', 'gadoe'),
],
'class' => [
'type' => 'String',
'description' => __('The CSS class for the icon', 'gadoe'),
],
'id' => [
'type' => 'String',
'description' => __('The ID of the icon', 'gadoe'),
],
'family' => [
'type' => 'String',
'description' => __('The icon family', 'gadoe'),
],
'style' => [
'type' => 'String',
'description' => __('The icon style', 'gadoe'),
],
'prefix' => [
'type' => 'String',
'description' => __('The prefix for the icon class', 'gadoe'),
],
'hex' => [
'type' => 'String',
'description' => __('The hex value of the icon', 'gadoe'),
],
'unicode' => [
'type' => 'String',
'description' => __('The unicode value of the icon', 'gadoe'),
],
],
]);
});
/** Register Font Awesome third party ACF field type * @see: https://acf.wpgraphql.com/adding-support-for-3rd-party-acf-field-type/ */add_action('wpgraphql/acf/registry_init', function () {
register_graphql_acf_field_type('font-awesome', [
'graphql_type' => staticfunction () {
return'FontAwesomeIcon';
},
]);
});
Register dummy options page and dummy icon field via ACF Admin or simply import provided fields export
Populate data for the new fields
Try to query data in GraphiQL IDE, if field was populated with the icon then data is returned but values are set to null, if icon is not populated null is returned.
Description
Hi, seems like after some updates there is an issue with the field resolution for custom registered field like for example FontAwesomeIcon (code provided in steps to reproduce).
I am successfully using this field that I registered just a couple of weeks ago on pages and also on the options page in some previously registered fields. However, when I try to register a new field of this type, it suddenly returns null for item attributes in GraphQL. The value is set and visible in the WP Admin, properly stored in the database, and the field is correctly resolved in the filter
graphql_resolve_field
. When I hook intographql_resolve_field
and dump the$result
value for this field, all data looks like the data I would expect to be returned by GraphQL. However, if the query is run, all object items contain a value of null. If the field does not have any value, null is returned as expected.Probably worth mentioning that if I colocate this new field just next to the working
icon
that is part of the repeatersocialIcons
FontAwesome field on the options page, it returns proper data and not nulls. In example belowiconFa
is the new icon that does not work in previous example.This looks like something similar that was happening here #128 , but I was not able to figure out what is going wrong between filters
graphql_resolve_field
where the correct value is resolved andgraphql_request_results
where the incorrect value is in the response and what plugin is responsible for introducing this strange behavior.To discard all the nuances mentioned above and the intricacies related to the setup, I have set up a vanilla testing environment with only the necessary plugins enabled and updated to the latest versions. I am getting null values for the options page registered field as well as for the field registered on the page. Could anyone please have a look at what is going wrong between the field resolution and what is actually returned by the WPGraphQL plugin?
Steps to reproduce
PHP or JSON export of the ACF Field Group(s)
add_action( 'acf/include_fields', function() {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}
) );
) );
} );
add_action( 'acf/init', function() {
acf_add_options_page( array(
'page_title' => 'Testing Option page',
'menu_slug' => 'testing-option-page',
'menu_title' => 'Testing Options Page',
'position' => 9999,
'redirect' => false,
'menu_icon' => array(
'type' => 'dashicons',
'value' => 'dashicons-admin-generic',
),
'icon_url' => 'dashicons-admin-generic',
'show_in_graphql' => true,
'graphql_type_name' => 'TestingOptionPage',
) );
} );
Additional context
No response
WPGraphQL Version
1.29.2
WPGraphQL For ACF Version
2.4.1
ACF (Advanced Custom Fields) Version. Free or Pro?
Pro: 6.3.11
WordPress Version
6.7.1
PHP Version
8.3.11
Additional enviornment details
Advanced Custom Fields: Font Awesome v4.1.1
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.
The text was updated successfully, but these errors were encountered: