-
Notifications
You must be signed in to change notification settings - Fork 121
Add support for ACF Blocks #327
base: develop
Are you sure you want to change the base?
Add support for ACF Blocks #327
Conversation
jasonbahl
commented
Jul 13, 2022
- update get_acf_field_value() to use the value if the $root is an array that has a key matching the acf field name
- update get_acf_field_value() to resolve fields from blocks using acf_setup_meta / acf_reset_meta
- update docblock / spacing for register_graphql_field
- update resolver for relationship field to compensate for root data coming in different shapes
- update resolver for image/file fields to use loader and compensate for root data in different shapes
- update resolver for gallery field to compensate for root data passed in different shapes
- update resolver for user field to use the deferred loader
- update get_all_graphql_types function to include blocks as locations that a field group can be assigned
…ray that has a key matching the acf field name - update get_acf_field_value() to resolve fields from blocks using acf_setup_meta / acf_reset_meta - update docblock / spacing for register_graphql_field - update resolver for relationship field to compensate for root data coming in different shapes - update resolver for image/file fields to use loader and compensate for root data in different shapes - update resolver for gallery field to compensate for root data passed in different shapes - update resolver for user field to use the deferred loader - update get_all_graphql_types function to include blocks as locations that a field group can be assigned
|
||
// @see: https://support.advancedcustomfields.com/forums/topic/getting-get_field-outside-block-loop/#post-84022 | ||
$block_id = isset( $root['attrs']['id'] ) ? $root['attrs']['id'] : null; | ||
acf_setup_meta( $root['attrs']['data'], $block_id, true ); |
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.
If $block_id
is null here, then acf_setup_meta
won't return data for the get_fields
call below.
I think you could swap this line (and 391 and 392) to:
$fields = acf_setup_meta( $root['attrs']['data'] );
to support both ACF5 and ACF6's upcoming changes - no need for get_fields()
as acf_setup_meta will return the fields for you.
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.
@lgladdy hmm. Making that change breaks for me.
This is something that will only work on v6?
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.
Shouldn't be... that logic hasn't been change. I'll test further!
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.
Turns out, acf_setup_meta
doesn't build and return the right structure for repeater (and repeater like) fields, so that's why it's erroring.
Instead of that route, changing from a null
block_id to a random block_{random-id}
will solve the issue for ACF6.
Any updates on this topic? |