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
I was trying to cleanup the GraphQL schema and I noticed that the "Show in GraphQL" option was not working for me. It was not removing a specific field from the schema of an active field group. Dug into the code and found an issue with this line of code:
Not sure the entire details of how PHP interprets a false here but this condition is not working properly for me: false === $this->acf_field['show_in_graphql']. When the "Show in GraphQL" is toggle false, the attribute 'show_in_graphql' returns a 0 and not false. I fixed this by using the function boolval like this: false === boolval( $this->acf_field['show_in_graphql'] ).
Hope this helps someone, it took me a bit of troubleshooting. Although it might not be a big deal for many people, for me is a big deal because we handle a very large website with tons of data, so it's important to have only the needed one in the Frontend. So deactivating a lot of fields will save tons of build time (we are using Gatsby to build and the queries are by themselves very heavy). I still don't know the entire implication in our build speed improvement but I did not want to hold myself from reporting this problem.
Thanks for all your hard work with these plugins!
Steps to reproduce
I am using WordPress 6.4.2 hosted on Gridpane PHP version 8.1.
Deactivated all plugins except: WPGraphQL, ACF Pro and WPGraphQL for ACF to avoid any possible plugin conflict.
Installed the Twenty Twenty One theme to avoid any possible theme conflict.
Create a new Field Group active in GraphQL.
Create a new field and deactivate it from GraphQL.
Assign the field group to post.
Query the newly created field group using the GraphiQL interface.
Desired behavior: The field group should appear empty because the only field inside the group is deactivated.
Current behavior: The field appears there with the default name.
@jasonbahl Thank you! I gave a quick look at the PR. Heads up that there are more instances in the code that require the (bool) casting. If you search the entire repo for 'show_in_graphql' you'll find those instances. In my case when I did not address the other cases, sometimes the fields kept appearing in the schema of GraphiQL interface.
Description
I was trying to cleanup the GraphQL schema and I noticed that the "Show in GraphQL" option was not working for me. It was not removing a specific field from the schema of an active field group. Dug into the code and found an issue with this line of code:
wpgraphql-acf/src/FieldConfig.php
Line 189 in 250b4e2
Not sure the entire details of how PHP interprets a false here but this condition is not working properly for me:
false === $this->acf_field['show_in_graphql']
. When the "Show in GraphQL" is toggle false, the attribute'show_in_graphql'
returns a0
and notfalse
. I fixed this by using the functionboolval
like this:false === boolval( $this->acf_field['show_in_graphql'] )
.Hope this helps someone, it took me a bit of troubleshooting. Although it might not be a big deal for many people, for me is a big deal because we handle a very large website with tons of data, so it's important to have only the needed one in the Frontend. So deactivating a lot of fields will save tons of build time (we are using Gatsby to build and the queries are by themselves very heavy). I still don't know the entire implication in our build speed improvement but I did not want to hold myself from reporting this problem.
Thanks for all your hard work with these plugins!
Steps to reproduce
Desired behavior: The field group should appear empty because the only field inside the group is deactivated.
Current behavior: The field appears there with the default name.
PHP or JSON export of the ACF Field Group(s)
Additional context
No response
WPGraphQL Version
1.19.0
WPGraphQL For ACF Version
2.0.0
ACF (Advanced Custom Fields) Version. Free or Pro?
6.2.4 Pro
WordPress Version
6.4.2
PHP Version
8.1
Additional enviornment details
Using the hosting of Gridpane. Frontend framework: Gatsby.
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: