-
Notifications
You must be signed in to change notification settings - Fork 120
Fix #135. Add Explicit options for adding ACF Field Groups to the Schema #207
Conversation
rsm0128
commented
Jan 19, 2021
- Added Explicit options for adding ACF Field Groups to the Schema
- Added explicit option auto-generation code for plugin upgrade from older versions.
Release/v0.3.4
Release/v0.3.5
Release/v0.4.0
…lowed WP convention for new code
@rsm0128 This is a great PR! I'll review it in detail shortly! Thanks for working on this 🙏 |
src/class-acfsettings.php
Outdated
acf_render_field_wrap( | ||
[ | ||
'label' => __( 'GraphQL Types to Show the Field Group On', 'wp-graphql-acf' ), | ||
'instructions' => __( 'Select the Types in the WPGraphQl Schema to show the fields in this fiedl group on', 'wp-graphql-acf' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error. Should be field
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the spelling. Thanks
Excited to see this working! |
I checked this branch out and tested it. With this you could pick something like Category (taxonomy), but you couldn't pick a specific category for it to show on. Also in WooCommerce, productCategory has the same name as regular post categories so they both show up here as Category (taxonomy). I don't think this solves the issue of being able to iterate over all available field groups for a given type. I'm thinking you have a store and products in a given productCategory have a series of field groups that could be applied to products inside a given category, or to all categories store-wide. We don't want to hunt for a set of specific names every time we load a product category but to simply get all of the field groups that apply to this context (viewing a category, or viewing any product), then we could show all of them. This does solve the problem of specifying multiple Location conditions not being shown at all ever. I could apply a complex ACF Field Group to all categories and they would show up everywhere with this. |
So the idea is that you opt into what TYPEs you want the field group to be on (as that is how the GQL schema works) and then you'd use the ACF location filters (and their existing API) for dictating where the field groups show up. This should allow you to say "I want this field group on CATEGORIES but only show up on the category called CARS). Does that help? |
I think my request is outside the scope of this fix. This does allow items to show up when you specify multiple locations. My request is more along the lines of getting an array of all the field groups and properties that apply to a given item. Which is currently not possible with the layout of wp-graphql-acf in general. You would need to know each name of each property you are asking for in graphql, of which I would need a more generic list of edges and nodes for all groups and all fields that apply to an item like a category. I've started developing a resolver to get edges for all fields but it's getting more and more complex. Namely there's no good generic way to specify all different types of fields as of yet. I would say this PR is good and works for what it's meant to. |
Thanks for this, with my limited testing, it works well! |
@rsm0128 I spoke with @jasonbahl and he'd like to get some test coverage for this PR. Can you do that (obviously I'm happy to pay for it). Any questions on setting up the tests, ask here. Thanks! |
Thanks @drewbaker ! |
@jasonbahl @drewbaker |