Skip to content

chore: Add compatibility for WPGraphQL 2.3.3 and lazy-loaded descriptions. #457

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

Merged
merged 4 commits into from
Jun 18, 2025

Conversation

justlevine
Copy link
Member

What

This PR adds support for WPGraphQL 2.3.x, including new support for lazy-loading descriptions.

A backwards-compatibility shim is used to support previous versions of WPGraphQL where a callable is not supported.

Why

How

Testing Instructions

Additional Info

Checklist:

  • This PR is tested to the best of my abilities.
  • This PR follows the WordPress Coding Standards.
  • This PR has proper inline documentation.
  • This PR has unit tests to verify the code works as intended.
  • The changes in this PR have been noted in CHANGELOG.md

@justlevine justlevine requested a review from Copilot June 18, 2025 20:28
Copilot

This comment was marked as outdated.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 15742948796

Details

  • 943 of 993 (94.96%) changed or added relevant lines in 246 files are covered.
  • 59 unchanged lines in 59 files lost coverage.
  • Overall coverage decreased (-0.7%) to 83.331%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Extensions/GFChainedSelects/Type/WPObject/FormField/FieldValue/ValueProperty.php 0 1 0.0%
src/Extensions/GFQuiz/Type/WPObject/Entry/EntryQuizResults.php 12 13 92.31%
src/Extensions/WPJamstackDeployments/WPJamstackDeployments.php 0 1 0.0%
src/Registry/FieldInputRegistry.php 2 3 66.67%
src/Type/WPInterface/FieldSetting/FieldWithAutocomplete.php 1 2 50.0%
src/Connection/EntriesConnection.php 29 31 93.55%
src/Connection/FormFieldsConnection.php 21 23 91.3%
src/Type/WPInterface/FieldChoiceSetting/ChoiceWithName.php 1 3 33.33%
src/Type/WPObject/Entry/SubmittedEntry.php 22 24 91.67%
src/Utils/Compat.php 28 30 93.33%
Files with Coverage Reduction New Missed Lines %
src/Extensions/GFChainedSelects/Type/Enum/ChainedSelectFieldAlignmentEnum.php 1 90.91%
src/Extensions/GFQuiz/Type/Enum/QuizFieldGradingTypeEnum.php 1 93.33%
src/Extensions/GFQuiz/Type/Enum/QuizFieldTypeEnum.php 1 93.33%
src/Extensions/GFQuiz/Type/WPInterface/FieldChoiceSetting/ChoiceWithQuizChoices.php 1 88.46%
src/Extensions/GFSignature/Type/Enum/SignatureFieldBorderStyleEnum.php 1 97.14%
src/Extensions/GFSignature/Type/Enum/SignatureFieldBorderWidthEnum.php 1 94.74%
src/Extensions/WPGraphQLContentBlocks/WPGraphQLContentBlocks.php 1 0.0%
src/Type/Enum/AddressFieldCountryEnum.php 1 90.0%
src/Type/Enum/AddressFieldProvinceEnum.php 1 90.0%
src/Type/Enum/AddressFieldStateEnum.php 1 90.0%
Totals Coverage Status
Change from base Build 15502392257: -0.7%
Covered Lines: 6394
Relevant Lines: 7673

💛 - Coveralls

@justlevine justlevine requested a review from Copilot June 18, 2025 20:40
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds backward compatibility for WPGraphQL versions prior to 2.3.0 by lazy-loading all description and deprecationReason properties, and updates the plugin metadata to reflect the new tested versions.

  • Bumped plugin header to test up to WordPress 6.8.1 and WPGraphQL 2.3.3
  • Introduced Compat::resolve_graphql_config to evaluate lazy-loaded configs on older WPGraphQL
  • Converted every GraphQL field/type description in src/Type/... to a static fn() => __() callable and wrapped object type registrations with the compatibility resolver

Reviewed Changes

Copilot reviewed 263 out of 264 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wp-graphql-gravity-forms.php Bump tested up-to versions for WP and WPGraphQL
src/Utils/Compat.php New helper for resolving lazy GraphQL configs
src/Type/WPObject/AbstractObject.php Wrapped object type registration with Compat::resolve_graphql_config
src/Type/... Converted all description/deprecationReason to lazy callables
src/Type/WPObject/*Entry.php Wrapped root query fields in compatibility resolver
Comments suppressed due to low confidence (3)

src/Utils/Compat.php:29

  • This comment is inverted: the code actually bails when the version is >= 2.3.0. Update the comment to say: "Bail if WPGraphQL version is 2.3.0 or greater, since those versions support lazy-loaded configs natively."
		// Bail if WPGraphQL version is less than 2.3.0, since WPGraphQL can handle it.

src/Utils/Compat.php:28

  • Consider adding unit tests for resolve_graphql_config, covering both branches (WPGraphQL >= 2.3.0 and < 2.3.0) and nested config resolution to ensure this helper works as intended.
	public static function resolve_graphql_config( array $config ): array {

src/Type/WPInterface/NodeWithForm.php:41

  • [nitpick] Interface type registrations currently skip the compatibility resolver. To keep behavior consistent, apply Compat::resolve_graphql_config when registering interface types in their register() methods, similar to object types in AbstractObject.
			'formDatabaseId' => [

@justlevine justlevine merged commit 2592f79 into develop Jun 18, 2025
10 of 11 checks passed
@justlevine justlevine deleted the chore/compatibility branch June 18, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants