diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c09fab..61d0cbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +- chore!: Bump minimum supported WPGraphQL version to v1.26.0. +- dev: Update `RedirectionConnectionResolver` for v1.26.0 compatibility. - fix: Correctly resolve `rankMathSettings.homepage.description` field. Props @offminded 🙌 - chore: Update Composer dev-dependencies to latest versions and address uncovered lints. - tests: Update compatibility with `wp-graphql-test-case@3.0.1`. diff --git a/README.md b/README.md index f812276..bd99269 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Adds WPGraphQL support for [Rank Math SEO](https://rankmath.com/). Built with [W * PHP 7.4 - 8.2+ * WordPress 6.0+ -* WPGraphQL 1.14.0+ +* WPGraphQL 1.26.0+ * RankMath SEO 1.0.201+ ## Quick Install diff --git a/readme.txt b/readme.txt index f59892b..d76ed61 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,8 @@ Tags: GraphQL, Gatsby, Headless, WPGraphQL, React, Rest, RankMath, Seo, Schema Requires at least: 6.0 Tested up to: 6.5.0 Requires PHP: 7.4 -Requires WPGraphQL: 1.14.0 +Requires Plugins: wp-graphql, seo-by-rank-math +Requires WPGraphQL: 1.26.0 Stable tag: 0.2.0 License: GPL-3 License URI: https://www.gnu.org/licenses/gpl-3.0.html diff --git a/src/Modules/Redirection/Data/Connection/RedirectionConnectionResolver.php b/src/Modules/Redirection/Data/Connection/RedirectionConnectionResolver.php index c769034..9a1f326 100644 --- a/src/Modules/Redirection/Data/Connection/RedirectionConnectionResolver.php +++ b/src/Modules/Redirection/Data/Connection/RedirectionConnectionResolver.php @@ -22,41 +22,33 @@ class RedirectionConnectionResolver extends AbstractConnectionResolver { /** * {@inheritDoc} - * - * @var ?array */ - protected $query; - - /** - * {@inheritDoc} - */ - public function get_loader_name() { + protected function loader_name(): string { return RedirectionsLoader::$name; } /** * {@inheritDoc} */ - public function get_query_args() { + protected function prepare_query_args( array $args ): array { /** * Prepare for later use */ - $last = ! empty( $this->args['last'] ) ? $this->args['last'] : null; - $first = ! empty( $this->args['first'] ) ? $this->args['first'] : null; + $last = ! empty( $args['last'] ) ? $args['last'] : null; $query_args = []; - if ( ! empty( $this->args['where']['search'] ) ) { - $query_args['search'] = $this->args['where']['search']; + if ( ! empty( $args['where']['search'] ) ) { + $query_args['search'] = $args['where']['search']; } - $query_args['status'] = ! empty( $this->args['where']['status'] ) ? $this->args['where']['status'] : 'active'; + $query_args['status'] = ! empty( $args['where']['status'] ) ? $args['where']['status'] : 'active'; - if ( ! empty( $this->args['where']['orderby']['field'] ) ) { - $query_args['orderby'] = $this->args['where']['orderby']['field']; + if ( ! empty( $args['where']['orderby']['field'] ) ) { + $query_args['orderby'] = $args['where']['orderby']['field']; } - $query_args['order'] = ! empty( $this->args['where']['orderby']['order'] ) ? $this->args['where']['orderby']['order'] : 'DESC'; + $query_args['order'] = ! empty( $args['where']['orderby']['order'] ) ? $args['where']['orderby']['order'] : 'DESC'; // If $last is set, we need to reverse the order. if ( ! empty( $last ) ) { @@ -66,18 +58,18 @@ public function get_query_args() { /** * Set limit the highest value of $first and $last, with a (filterable) max of 100 */ - $query_args['limit'] = $this->one_to_one ? 1 : min( max( absint( $first ), absint( $last ), 10 ), $this->query_amount ) + 1; + $query_args['limit'] = $this->one_to_one ? 1 : $this->get_query_amount() + 1; /** * Set the before and after cursors. This will modify the query in CoreSchemaFilters::add_redirection_pagination_support() */ $query_args['graphql_cursor_compare'] = ! empty( $last ) ? '>' : '<'; - if ( ! empty( $this->args['after'] ) ) { + if ( ! empty( $args['after'] ) ) { $query_args['graphql_after_cursor'] = $this->get_after_offset(); } - if ( ! empty( $this->args['before'] ) ) { + if ( ! empty( $args['before'] ) ) { $query_args['graphql_before_cursor'] = $this->get_before_offset(); } @@ -87,27 +79,27 @@ public function get_query_args() { /** * {@inheritDoc} */ - public function get_query() { - if ( ! isset( $this->query ) ) { - $query = RMUtils::get_redirections( $this->query_args ?? [] ); + protected function query( array $query_args ) { + $query = RMUtils::get_redirections( $query_args ); - // Prime the cache for each of the queried redirections. - $loader = $this->getLoader(); + // Prime the cache for each of the queried redirections. + $loader = $this->get_loader(); + if ( isset( $query['redirections'] ) ) { foreach ( $query['redirections'] as $redirection ) { $loader->prime( $redirection['id'], $redirection ); } - - $this->query = $query; } - return $this->query; + return $query; } /** * {@inheritDoc} */ public function should_execute() { - if ( isset( $this->query_args['status'] ) && 'active' === $this->query_args['status'] ) { + $query_args = $this->get_query_args(); + + if ( isset( $query_args['status'] ) && 'active' === $query_args['status'] ) { return true; } @@ -126,7 +118,8 @@ public function is_valid_offset( $offset ) { */ public function get_ids_from_query() { $ids = []; - $queried = $this->query['redirections'] ?? []; + $query = $this->get_query(); + $queried = ! empty( $query['redirections'] ) ? $query['redirections'] : []; if ( empty( $queried ) ) { return $ids; @@ -135,7 +128,8 @@ public function get_ids_from_query() { $ids = array_column( $queried, 'id' ); // If we're going backwards, we need to reverse the array. - if ( ! empty( $this->args['last'] ) ) { + $args = $this->get_args(); + if ( ! empty( $args['last'] ) ) { $ids = array_reverse( $ids ); } diff --git a/wp-graphql-rank-math.php b/wp-graphql-rank-math.php index 9ef23c0..dd82483 100644 --- a/wp-graphql-rank-math.php +++ b/wp-graphql-rank-math.php @@ -14,7 +14,7 @@ * Tested up to: 6.5.0 * Requires PHP: 7.4 * Requires Plugins: wp-graphql, seo-by-rank-math - * WPGraphQL requires at least: 1.14.0 + * WPGraphQL requires at least: 1.26.0 * License: GPL-3 * License URI: https://www.gnu.org/licenses/gpl-3.0.html * @@ -96,7 +96,7 @@ function constants(): void { * @return array List of dependencies that are not ready. */ function dependencies_not_ready(): array { - $wpgraphql_version = '1.14.0'; + $wpgraphql_version = '1.26.0'; $rankmath_version = '1.0.201'; $deps = [];