Skip to content

Commit

Permalink
feat: review filters, and confirm they are working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
moonmeister committed Oct 13, 2022
1 parent aac0bf2 commit a6cf76c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/Connection/GuestCommenters.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,30 +68,18 @@ public static function get_connection_args() {
'type' => 'String',
'description' => __( 'Guest commenter email address.', 'wp-graphql' ),
],
'authorIn' => [
'type' => [
'list_of' => 'ID',
],
'description' => __( 'Array of author IDs to include comments for.', 'wp-graphql' ),
'authorUrl' => [
'type' => 'String',
'description' => __( 'Guest commenter domain', 'wp-graphql' ),
],
'orderby' => [
'type' => 'GuestCommenterOrderbyEnum',
'description' => __( 'Field to order the comments by.', 'wp-graphql' ),
],
'authorNotIn' => [
'type' => [
'list_of' => 'ID',
],
'description' => __( 'Array of author IDs to exclude comments for.', 'wp-graphql' ),
'order' => [
'type' => 'OrderEnum',
'description' => __( 'The cardinality of the order of the connection', 'wp-graphql' ),
],
// 'orderby' => [
// 'type' => 'CommentsConnectionOrderbyEnum',
// 'description' => __( 'Field to order the comments by.', 'wp-graphql' ),
// ],
// 'order' => [
// 'type' => 'OrderEnum',
// 'description' => __( 'The cardinality of the order of the connection', 'wp-graphql' ),
// ],
// 'search' => [
// 'type' => 'String',
// 'description' => __( 'Search term(s) to retrieve matching comments for.', 'wp-graphql' ),
// ],
];
}
}
2 changes: 2 additions & 0 deletions src/Registry/TypeRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
use WPGraphQL\Type\Enum\TermNodeIdTypeEnum;
use WPGraphQL\Type\Enum\UserNodeIdTypeEnum;
use WPGraphQL\Type\Enum\GuestCommenterIdTypeEnum;
use WPGraphQL\Type\Enum\GuestCommenterOrderbyEnum;
use WPGraphQL\Type\Enum\UsersConnectionOrderbyEnum;
use WPGraphQL\Type\Input\UsersConnectionOrderbyInput;
use WPGraphQL\Type\InterfaceType\CommenterInterface;
Expand Down Expand Up @@ -308,6 +309,7 @@ public function init_type_registry( TypeRegistry $type_registry ) {

AvatarRatingEnum::register_type();
GuestCommenterIdTypeEnum::register_type();
GuestCommenterOrderbyEnum::register_type();
CommentsConnectionOrderbyEnum::register_type();
CommentNodeIdTypeEnum::register_type();
ContentNodeIdTypeEnum::register_type();
Expand Down
33 changes: 33 additions & 0 deletions src/Type/Enum/GuestCommenterOrderbyEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
namespace WPGraphQL\Type\Enum;

class GuestCommenterOrderbyEnum {

/**
* Register the GuestCommenterOrderbyEnum Type to the Schema
*
* @return void
*/
public static function register_type() {
register_graphql_enum_type(
'GuestCommenterOrderbyEnum',
[
'description' => __( 'Options for ordering the connection', 'wp-graphql' ),
'values' => [
'NAME' => [
'description' => __( 'Order by name of the guest commenter.', 'wp-graphql' ),
'value' => 'comment_author',
],
'EMAIL' => [
'description' => __( 'Order by e-mail of the guest commenter.', 'wp-graphql' ),
'value' => 'comment_author_email',
],
'URL' => [
'description' => __( 'Order by URL address of the guest commenter.', 'wp-graphql' ),
'value' => 'comment_author_url',
],
],
]
);
}
}

0 comments on commit a6cf76c

Please sign in to comment.