Skip to content

Conversation

jasonbahl
Copy link
Contributor

@jasonbahl jasonbahl commented May 10, 2023

What does this implement/fix? Explain your changes.

This adds support for ACF Options Pages to be exposed to the WPGraphQL Schema and queried for.

What currently open issues does this close or contribute?

closes #39

Any other comments?

ACF Options pages are now exposed to the GraphQL Schema.

I can register an ACF Options Page like so:

if ( function_exists( 'acf_add_options_page' ) )  {
	acf_add_options_page(
		[
			'page_title' => 'My Options Page',
			'menu_title' => __( 'My Options Page' ),
			'menu_slug'  => 'my-options-page',
			'capability' => 'edit_posts',
		]
	);
}

I can then assign an ACF Field Group to the Options Page:

CleanShot 2023-05-10 at 14 17 46

I will see that the GraphQL Settings for the field group map the Field Group to the GraphQL Type that represents the options page:

CleanShot 2023-05-10 at 14 18 19

I can update values in the Options Page:

CleanShot 2023-05-10 at 14 20 58

And then I can query the options page and the associated Field Group(s)

CleanShot 2023-05-10 at 14 23 46

Bonus: WPGraphQL Smart Cache Support

This also works with WPGraphQL Smart Cache, so my queries for ACF Options can be cached and when updating an options page, queries for that options page will be purged, so we can have fresh data always!

We can see in the WPGraphQL Smart Cache Logs that purge events are happening when I update ACF Options:

CleanShot 2023-05-10 at 14 25 50

@jasonbahl jasonbahl self-assigned this May 10, 2023
@jasonbahl jasonbahl added the type: enhancement Improvements to existing functionality label May 10, 2023
@github-actions
Copy link

Pull Request Test Coverage Report for Build 573d1d75e9018e98a412f952e9817f9b9350c013-PR-41

  • 119 of 162 (73.46%) changed or added relevant lines in 10 files are covered.
  • 6 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+1.3%) to 53.542%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Admin/Settings.php 0 1 0.0%
src/Model/AcfOptionsPage.php 15 16 93.75%
src/Data/Loader/AcfOptionsPageLoader.php 8 10 80.0%
src/ThirdParty.php 0 2 0.0%
src/WPGraphQLAcf.php 5 8 62.5%
src/Registry.php 58 62 93.55%
src/FieldType/FlexibleContent.php 0 6 0.0%
src/ThirdParty/WPGraphQLSmartCache/WPGraphQLSmartCache.php 0 10 0.0%
src/Utils.php 31 45 68.89%
Files with Coverage Reduction New Missed Lines %
src/Admin/Settings.php 1 0%
src/WPGraphQLAcf.php 1 16.13%
src/FieldType/FlexibleContent.php 2 58.33%
src/Utils.php 2 44.36%
Totals Coverage Status
Change from base Build ad6556c517898c2db9b6745c3d5bcf6fbefddede: 1.3%
Covered Lines: 1383
Relevant Lines: 2583

💛 - Coveralls

@jasonbahl jasonbahl merged commit ceb0c34 into main May 10, 2023
@jasonbahl jasonbahl deleted the feat/#39-options-pages-support branch January 24, 2024 20:03
@coveralls
Copy link

coveralls commented Nov 24, 2024

Pull Request Test Coverage Report for Build f255617bebc3dad9a4d80f8666997ce8f81f9d76-PR-41

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 119 of 157 (75.8%) changed or added relevant lines in 9 files are covered.
  • 4 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+1.2%) to 53.918%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Admin/Settings.php 0 1 0.0%
src/Data/Loader/AcfOptionsPageLoader.php 8 10 80.0%
src/Model/AcfOptionsPage.php 15 17 88.24%
src/ThirdParty.php 0 2 0.0%
src/WPGraphQLAcf.php 5 8 62.5%
src/Registry.php 58 62 93.55%
src/ThirdParty/WPGraphQLSmartCache/WPGraphQLSmartCache.php 0 10 0.0%
src/Utils.php 31 45 68.89%
Files with Coverage Reduction New Missed Lines %
src/Admin/Settings.php 1 0.0%
src/WPGraphQLAcf.php 1 16.13%
src/Utils.php 2 44.36%
Totals Coverage Status
Change from base Build ad6556c517898c2db9b6745c3d5bcf6fbefddede: 1.2%
Covered Lines: 1273
Relevant Lines: 2361

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ACF Options Pages support
2 participants