Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: relationship field should use graphql_acf_post_object_source filter #297

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ardiewen
Copy link

@ardiewen ardiewen commented Oct 19, 2021

SUMMARY

Fixes #155 and #272 when used in conjunction with PR on woographql: wp-graphql/wp-graphql-woocommerce#568

EXPLANATION

The relationship field in class config does not call graphql_acf_post_object_source like the post_object field does. By offloading the logic to wp-graphql-woocommerce, we can allow the filter to process additional post object types such as Products.

NOTES

  • NOTE: This is only a temporary fix as significant schema changes are expected in wp-graphql-acf 0.6.0.

  • NOTE: This does NOT resolve another edge case where an error will be thrown when no post type filters are set on the custom field. This is because when no filter is set, the $acf_field['post_type'] is set to an empty string, causing the type of the post_object or relationship to be defaulted to PostObjectUnion type.

@jacobarriola
Copy link
Contributor

Hey @ardiewen! I think I have an open PR #177 that's trying to solve the same problem. 🤔

It's been a while though, so I could be wrong.

@ardiewen
Copy link
Author

Hey @jacobarriola, yes indeed it looks like the same problem with a slightly different solution.

Looks like you are offering a new filter for relationships whereas I'm hooking into the existing one for post_objects that is used by woographql.

I think either solution could work, as both require an update in woographql to resolve this particular issue anyway 🤷🏻‍♂️.

@jasonbahl it would be great if we could get one of these temp solutions merged, as new users keep running into the same issues with these post object and relationship fields. Given the timelines on v0.6.0, I think this would provide some value, even if it isn't directionally correct with the future of the plugin. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Post Object field and Relationship field return null for arrays.
2 participants