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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

New filter: allow non-core post types in Relationship ACF field #177

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

Conversation

jacobarriola
Copy link
Contributor

The current logic assumes that all post models are instances of the Post model. Unfortunately, when non-core post types such as WooCommerce are part of this request, the result is an internal error (see screenshot).

This filter would make it possible for extensions to properly set the correct source Type, thereby fulfilling the request. A similar filter already exists (graphql_acf_post_object_source) for the post_object field type; this new filter tries to follow the same pattern.

An example implementation would be identical to graphql_acf_post_object_source. See https://github.com/wp-graphql/wp-graphql-woocommerce/blob/develop/includes/class-acf-schema-filters.php#L56

Screenshots

Error when no filter is in place 馃憞馃徑
image

Relationship field filtering only Product post type 馃憞馃徑
image

Without this filter, non-core types (ie WooCommerce) cannot declare their proper Type source. This filter is inline with the `graphql_acf_post_object_source` filter on line 617.
@jacobarriola
Copy link
Contributor Author

馃憢馃徑 hey @jasonbahl - have you had a chance to look at this PR? Happy to discuss. Thanks!

@jasonbahl
Copy link
Contributor

@jacobarriola I think this field is going to be changing to become a formal one-to-one connection, now that WPGraphQL core has formal support for them.

And with that, this will now use the Post Object Loader, which has filters more centrally. So instead of having to filter every specific field in the Graph that might return something like a WooCommerce product, WooCommerce could filter the loader / model layer more centrally and work with the rest of the Graph.

I'm going to leave this PR open, for now, to keep it fresh as we work on updating things like making relationship-type fields proper connections, etc, and provide documentation for how to overcome some of these scenarios this filter is intended to address.

@jacobarriola
Copy link
Contributor Author

Ok, great @jasonbahl. I'm currently working off of a forked repo, so I'd like to get back on the main project as soon as possible. Thanks! 馃檹

Is there anything I can do to help?

@jacobarriola
Copy link
Contributor Author

Hi @jasonbahl 馃憢馃徑

Just a friendly nudge to move this to the top of your inbox. Not sure how progress is coming along with the Post Object Loader and how it impacts this PR.

Thanks!

@gvocale
Copy link

gvocale commented Aug 18, 2021

Friendly reminder @jasonbahl ! This is helping me as well! Would be nice to work not off a forked repo 馃槃

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

Successfully merging this pull request may close these issues.

None yet

3 participants