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

release: v2.0.0 beta.5.0.0 #88

Merged
merged 31 commits into from
Sep 25, 2023
Merged

release: v2.0.0 beta.5.0.0 #88

merged 31 commits into from
Sep 25, 2023

Conversation

jasonbahl
Copy link
Contributor

@jasonbahl jasonbahl commented Sep 12, 2023

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.

register-block-type

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.

acf-block-fields

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.

CleanShot 2023-09-14 at 09 26 44

Use the Block in Content

Next, you can use the block in your content.

CleanShot 2023-09-14 at 09 28 38

Query for the Block

Now you can query for EditorBlocks, and specify fields you want for your specific ACF Blocks:

CleanShot 2023-09-14 at 09 44 49


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.

CleanShot 2023-09-06 at 15 22 22

You will see the data in the columns on the list options page as well:

CleanShot 2023-09-06 at 15 27 55

Assign a Field Group

If you assign an ACF Field Group to the Options Page:

CleanShot 2023-09-06 at 15 28 53

You will be able to see that the ACF Field Group is associated with the Options Page Type

CleanShot 2023-09-06 at 15 29 33

Query the Options

Then you can fill in values for the options page:

CleanShot 2023-09-06 at 15 30 35

And query for the options in GraphQL:

CleanShot 2023-09-06 at 15 31 47

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',
	]
);

…graphql_field_name"

- add support for OptionsPage UI from ACF v6.2+
- add 'wpgraphql/acf/type_registry/init' hook
- use get_parent_graphql_type_name on repeater, group and flex field field types
…v2.0.0-beta.5.0.0

# Conflicts:
#	src/FieldType/Taxonomy.php
…lution

- update WPgraphQLContentBlocks to register all ACF Blocks
- remove wpunit test for testClonedFieldGroupIsAppliedAsInterface
- introduced Clone Field interface tests as functional tests
….0.0-beta.5.0.0

# Conflicts:
#	src/LocationRules/LocationRules.php
#	src/ThirdParty/WPGraphQLContentBlocks/WPGraphQLContentBlocks.php
@jasonbahl jasonbahl added the release Pull request intended for a release label Sep 12, 2023
@jasonbahl jasonbahl self-assigned this Sep 12, 2023
- add haveAcfProActive test util to be able to run/skip tests if acf pro is not active
- update tests to skip if acf pro is not active
@github-actions
Copy link

Pull Request Test Coverage Report for Build 1d1daf06f8b3c120dbf46c952dfa262e648f5cac-PR-88

  • 56 of 174 (32.18%) changed or added relevant lines in 11 files are covered.
  • 6 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-1.3%) to 57.613%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/FieldType/FlexibleContent.php 5 6 83.33%
src/FieldType/Taxonomy.php 8 9 88.89%
src/WPGraphQLAcf.php 0 3 0.0%
src/Registry.php 18 22 81.82%
src/FieldConfig.php 12 18 66.67%
src/LocationRules/LocationRules.php 0 6 0.0%
src/ThirdParty/WPGraphQLContentBlocks/WPGraphQLContentBlocks.php 0 24 0.0%
src/Admin/OptionsPageRegistration.php 0 73 0.0%
Files with Coverage Reduction New Missed Lines %
src/FieldConfig.php 1 77.19%
src/ThirdParty/WPGraphQLContentBlocks/WPGraphQLContentBlocks.php 1 0.0%
src/LocationRules/LocationRules.php 4 45.5%
Totals Coverage Status
Change from base Build 3b402e041b3237808edae54f6ab746b61399e038: -1.3%
Covered Lines: 1820
Relevant Lines: 3159

💛 - Coveralls

@jasonbahl jasonbahl mentioned this pull request Sep 18, 2023
5 tasks
…tup.sh

- remove deleteAllFieldGroups util
- remove unused AssertValidSchemaTest
- fix duplicate field issues for types that register connections
- remove duplicate config for relationship field
- update how WPGraphQL Content Blocks is installed in app.setup.sh
-
…d_config->prepare_acf_field_value()`

- apply wpautop to wysiwyg field type
- update how connections are cached to ensure they're not registered multiple times in FieldConfig->register_graphql_connections()
- update how we bail if WPGraphQL Content Blocks is not active
- add test helpers for testing fields against blocks
@jasonbahl jasonbahl merged commit 2517a5b into main Sep 25, 2023
21 of 22 checks passed
@jasonbahl jasonbahl deleted the release/v2.0.0-beta.5.0.0 branch January 24, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Pull request intended for a release
Projects
None yet
1 participant