Skip to content

Commit

Permalink
chore: cleanup after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Sep 16, 2023
1 parent 4c6e03c commit 218c30d
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 145 deletions.
41 changes: 23 additions & 18 deletions src/Data/Connection/AbstractConnectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
namespace WPGraphQL\Data\Connection;

use Exception;
use GraphQL\Deferred;
use GraphQL\Error\UserError;
use GraphQL\Type\Definition\ResolveInfo;
use WPGraphQL\AppContext;
use WPGraphQL\Model\Post;

/**
* Class AbstractConnectionResolver - Shim for ConnectionResolver 2.0
Expand Down Expand Up @@ -119,11 +116,14 @@ public function setQueryArg( $key, $value ) {
*
* {@inheritDoc}
*/
protected function loader_name() : string {
throw new Exception( sprintf(
__( 'Class %s does not implement a valid method `loader_name()`.', 'wp-graphql' ),
get_class( $this )
) );
protected function loader_name(): string {
throw new Exception(
sprintf(
// translators: %s is the name of the connection resolver class.
esc_html__( 'Class %s does not implement a valid method `loader_name()`.', 'wp-graphql' ),
static::class
)
);
}

/**
Expand All @@ -134,10 +134,13 @@ protected function loader_name() : string {
* {@inheritDoc}
*/
protected function prepare_query_args( array $args ): array {
throw new Exception( sprintf(
__( 'Class %s does not implement a valid method `prepare_query_args()`.', 'wp-graphql' ),
get_class( $this )
) );
throw new Exception(
sprintf(
// translators: %s is the name of the connection resolver class.
esc_html__( 'Class %s does not implement a valid method `prepare_query_args()`.', 'wp-graphql' ),
static::class
)
);
}

/**
Expand All @@ -155,11 +158,14 @@ protected function prepare_query_args( array $args ): array {
*
* {@inheritDoc}
*/
public function get_ids_from_query() : array {
throw new Exception( sprintf(
__( 'Class %s does not implement a valid method `get_ids_from_query()`.', 'wp-graphql' ),
get_class( $this )
) );
public function get_ids_from_query(): array {
throw new Exception(
sprintf(
// translators: %s is the name of the connection resolver class.
esc_html__( 'Class %s does not implement a valid method `get_ids_from_query()`.', 'wp-graphql' ),
static::class
)
);
}

/**
Expand Down Expand Up @@ -195,5 +201,4 @@ public function get_offset() {
/**
* Method `get_page_info()` should now be overloaded via `prepare_page_info()`.
*/

}
14 changes: 6 additions & 8 deletions src/Data/Connection/CommentConnectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace WPGraphQL\Data\Connection;

use GraphQL\Error\UserError;
use WP_Comment_Query;
use WPGraphQL\Utils\Utils;

/**
Expand All @@ -22,14 +21,14 @@ class CommentConnectionResolver extends AbstractConnectionResolver {
/**
* {@inheritDoc}
*/
protected function loader_name() : string {
protected function loader_name(): string {
return 'comment';
}

/**
* {@inheritDoc}
*/
protected function prepare_query_args( array $args ) : array {
protected function prepare_query_args( array $args ): array {

/**
* Prepare for later use
Expand Down Expand Up @@ -148,14 +147,14 @@ protected function prepare_query_args( array $args ) : array {
/**
* {@inheritDoc}
*/
protected function query_class() : string {
protected function query_class(): string {
return 'WP_Comment_Query';
}

/**
* {@inheritDoc}
*/
public function get_ids_from_query() : array {
public function get_ids_from_query(): array {
/** @var array $ids */
$ids = ! empty( $this->query->get_comments() ) ? $this->query->get_comments() : [];

Expand All @@ -170,14 +169,14 @@ public function get_ids_from_query() : array {
/**
* {@inheritDoc}
*/
public function is_valid_offset( $offset ) : bool {
public function is_valid_offset( $offset ): bool {
return ! empty( get_comment( $offset ) );
}

/**
* {@inheritDoc}
*/
protected function prepare_args( array $args ) : array {
protected function prepare_args( array $args ): array {
if ( ! empty( $args['where'] ) ) {
// Ensure all IDs are converted to database IDs.
foreach ( $args['where'] as $input_key => $input_value ) {
Expand Down Expand Up @@ -296,5 +295,4 @@ public function sanitize_input_fields( array $args ) {

return ! empty( $query_args ) && is_array( $query_args ) ? $query_args : [];
}

}

0 comments on commit 218c30d

Please sign in to comment.