v2.0.0-beta.5.0.0
Release Notes:
New Features
- ACF Blocks Support: see below for more details
- ACF Options Page UI Support: see below for more details (closes #83)
Chores / Bugfixes
- fix: cloning one field was applying the cloned field's field group Interface, leading to additional fields mistakenly showing in the schema (closes #78)
- ci: add acf-pro-stubs for phpstan
- fix: clone field resolver bugs on nested groups (flex layouts, repeaters)
- #85 fix: TermNodes returning null when not array and fix type being set to generic TermNode in Taxonomy field
ACF Blocks Support
This release includes support for ACF Blocks (a premium feature of ACF Pro), while also using WPGraphQL Content Blocks v1.2.0+.
The WPGraphQL Content Blocks plugin is responsible for exposing Editor Blocks to the GraphQL Schema, and now ACF Blocks and their associated ACF Field Groups can be queried as GraphQL Types
Registering ACF Blocks
You can register ACF Blocks using code or using ACF Extended's Block Types UI.
Adding ACF Field Groups to ACF Blocks
ACF Pro allows ACF Field Groups to be assigned to ACF Blocks as a location.
After you've assigned an ACF Field Group to an ACF Block, that field group can be accessed from the block.
Example
Register the Block
Here's an example of registering an ACF Block using ACF Extended's Block Type UI. You could also register the block using code, following ACF's block registration examples.
Assign a Field Group to the Block
Then, using ACF's Field Group UI (or using JSON or PHP) you can create an ACF Field Group and associate it with an ACF Block.
See the Block in the GraphQL Schema
Next, you should be able to see the Block and the ACF Field Group associated with the block in the GraphQL Schema.
Use the Block in Content
Next, you can use the block in your content.
Query for the Block
Now you can query for EditorBlocks, and specify fields you want for your specific ACF Blocks:
ACF Options Page UI Support
ACF Pro v6.2+ introduced support for creating Options Pages using the ACF User Interface.
Now you can configure these option pages to show in the GraphQL Schema using the UI.
Here's how it works 👇🏻
Configure Options Page
When registering an Options Page via the ACF PRO v6.2+ UI, you can configure the Options Page to show in graphql, and set the GraphQL Type Name.
You will see the data in the columns on the list options page as well:
Assign a Field Group
If you assign an ACF Field Group to the Options Page:
You will be able to see that the ACF Field Group is associated with the Options Page Type
Query the Options
Then you can fill in values for the options page:
And query for the options in GraphQL:
Registering ACF Option Pages in code
You can still register options pages in PHP as you did before, adding fields graphql_type_name
and show_in_graphql
like shown below:
acf_add_options_page(
[
'page_title' => 'OptionsPageNode',
'menu_title' => __( 'Options Page Node' ),
'menu_slug' => 'options-page-node',
'capability' => 'edit_posts',
show_in_graphql' => true,
'graphql_type_name' => 'OptionsPageNode',
]
);
New Contributors
- @cristobalbahe made their first contribution in #85
Full Changelog: v2.0.0-beta.4.0.0...v2.0.0-beta.5.0.0