ACF Post Object filter: guard against empty post id#407
Conversation
This guard prevents unexpected query results. There could be instances where the post id isn't available because an end-user saved an empty value in the WP admin UI. It is better to get a null value instead of the incorrect product/order/coupon result. Related to wp-graphql#406
|
Hey @kidunot89 👋🏽 I'm going to be stepping away during the holidays soon, so let me know whether this PR seems acceptable to you or whether I need to make some changes. Thanks! |
kidunot89
left a comment
There was a problem hiding this comment.
@jacobarriola Sorry, for the delay on this review. Great work on this 👍
kidunot89
left a comment
There was a problem hiding this comment.
@jacobarriola Upon further review, this function may not be necessary anymore.
I suggest changing Line 26 to add_filter( 'graphql_acf_post_object_source', array( '\WPGraphQL\WooCommerce\Data\Loader\WC_CPT_Loader', 'resolve_model' ), 10, 2 );
|
@kidunot89 Sounds good. I'll take look and test it out. |
|
@jacobarriola There is however an core design issue that is preventing Products and other WPGraphQL Costs from being registered to WPGraphQL core |
|
@kidunot89 With regards to the design issue, is this the issue you're referring to? wp-graphql/wp-graphql-acf#177 |
|
@jacobarriola This shouldn't be necessary after the next release. Even less so have the next major release of WPGraphQL ACF. |
What does this implement/fix? Explain your changes.
Adds a guard against the post id when attempting to set the correct Type source for an ACF Post Object field. This guard will return the correct value (
null) instead of an unexpected query result (incorrect/duplicate product/order/coupon).There could be instances where the post id is empty because an end-user saved an empty value in the WP admin UI. It is better to get a
nullvalue instead of the incorrect product/order/coupon result.For more details, see #406
Does this close any currently open issues?
#406