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
feat: Root Entry points for GuestCommenter #2577
base: develop
Are you sure you want to change the base?
Conversation
src/Type/ObjectType/RootQuery.php
Outdated
break; | ||
} | ||
|
||
return ! empty( $id ) ? DataSource::resolve_guest_commenter( $id, $context ) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
* @return array | ||
*/ | ||
public static function get_connection_args() { | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
@moonmeister it's not just the dataloader keys that have me concerned, but also the breaking PHP class names/files and the type name changes themselves. Are all/any of these essential just to expose commenters to the I assume we want this feature merged before a major release, but without #2543 this will break pretty much every single site using comments (and likely a few plugins) overnight. Even if users could fix their site after-the-fact with a filter (a lot of what's included cant be reverted with existing filters), in the past we've only relied on such a 'workaround' when the breaking changes were absolutely necessary. I worry this is a very bad precedent just to (albeit justifiably) improve the semantic naming of a GraphQL type that's been in use since 2019, unless it's otherwise essential to shipping these changes. Thoughts? |
@moonmeister @justlevine I think there is a backward compatible way to do this. (sorry, @moonmeister. I should have been able to clearly think of this yesterday 🤦🏻♂️). I think we can introduce a new I believe the only field that resolves to If we deprecate that field (but leave it), and introduce a new field, something like Existing users querying for Then, sometime in the future when we believe most users have likely switched to using the new |
All makes sense. The type chances are not necessary. I can change it to Jason's suggestion or just not worry about it and we can make the changes later during a major release. |
I like @jasonbahl 's suggestion too, that way we can continue to iterate on the new type without getting held up by back-compat. Speaking in broad terms, I suggest we use the new/future names for the new PHP classes/types, but keep the existing dataloader key. As far as the existing PHP classes, instead of renaming them entirely, I think they should extend the new classes with a deprecation warning, so users can prepare for the eventual breaking change at their leisure. |
8020c21
to
aca653e
Compare
* | ||
* @return void | ||
*/ | ||
public static function register_type() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method register_type
has 71 lines of code (exceeds 40 allowed). Consider refactoring.
return current_user_can( 'moderate_comments' ) && ! empty( $this->data->comment_author_email ) ? $this->data->comment_author_email : null; | ||
}, | ||
'url' => function () { | ||
return ! empty( $this->data->comment_author_url ) ? $this->data->comment_author_url : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
@@ -0,0 +1,104 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
@@ -0,0 +1,70 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
'connectionInterfaces' => [ 'CommentWriterConnection' ], | ||
'description' => __( 'The author of the comment', 'wp-graphql' ), | ||
'oneToOne' => true, | ||
'resolve' => function ( $comment, $args, AppContext $context, ResolveInfo $info ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
@@ -0,0 +1,73 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
* | ||
* @return void | ||
*/ | ||
public static function register_type( TypeRegistry $type_registry ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method register_type
has 45 lines of code (exceeds 40 allowed). Consider refactoring.
Okay. SO new Types create, new interfaces and new |
@moonmeister would you mind fixing the phpcs / phpstan issues?
Looks like we're going to need them, especially around the id type resolution. I'm happy to lend a hand if you want 😎 |
break; | ||
} | ||
|
||
return ! empty( $id ) ? DataSource::resolve_guest_commenter( $id ) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid too many return
statements within this method.
@justlevine Help with Tests would be great. I'm working on that last phpcs comment warning. Needed to revisit the filters anyway. |
Code Climate has analyzed commit a6cf76c and detected 14 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Where are we at on this? Is it waiting for tests or something else? |
@moonmeister I just tried reviewing /rebasing this locally in order to start working on tests, but I'm not entirely sure which of these changes are intentional vs cosmetic, or what is actually is supposed to be happening since the force-push vs what was originally described in the PR description. Seems there's also still some breaking changes like the removal of If you can provide some direction I'd love to give it another attempt 🤞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justlevine Here are some comments. Hopefully, this is helpful. my memory ain't so good. No comments meant it seemed important. Maybe not correct...but 🤷🏻
@@ -82,7 +82,7 @@ case "$subcommand" in | |||
WP_VERSION=${WP_VERSION} PHP_VERSION=${PHP_VERSION} docker compose up app | |||
;; | |||
t ) | |||
docker-compose run --rm \ | |||
docker compose run --rm \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker changed how compose is executed. I'm not sure if I was the only one having the issue, but if y'all aren't having issues this probably doesn't need to carry over.
'nav_menu_item' => new PostObjectLoader( $this ), | ||
'plugin' => new PluginLoader( $this ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was cosmetic to keep with the alphabetical list.
@@ -105,8 +105,8 @@ public static function mutate_and_get_payload() { | |||
} else { | |||
// Get the current user id | |||
$current_user_id = absint( get_current_user_id() ); | |||
// If the current user ID is the same as the comment author's ID, then the | |||
// current user is the comment author and can delete the comment | |||
// If the current user ID is the same as the commenter's ID, then the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosmetic. I think I was trying to keep consistent language through out the code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cosmetic for consistent language
@@ -26,10 +26,11 @@ public static function register_type() { | |||
'model' => CommentModel::class, | |||
'interfaces' => [ 'Node', 'DatabaseIdentifier' ], | |||
'connections' => [ | |||
'author' => [ | |||
'author' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cosmetic
'toType' => 'Commenter', | ||
'connectionInterfaces' => [ 'CommenterConnection' ], | ||
'description' => __( 'The author of the comment', 'wp-graphql' ), | ||
'deprecationReason' => __( 'Deprecated in favor of `authoredBy`', 'wp-graphql' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cosmetic for consistent language
@@ -630,13 +630,46 @@ function ( $post ) use ( $allowed_post_types ) { | |||
|
|||
}, | |||
], | |||
'viewer' => [ | |||
'viewer' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs are all cosmetic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks cosmetic.
What does this implement/fix? Explain your changes.
Makes comment authors who are not
Users
(akaGuestCommenters
), available to be queried from the RootQuery.GuestCommenter
type has replacedCommentAuthor
type in hopes of clarifying the difference betweenUser
andnon-User
comment authors. This also helps pave the way forcommenter(s)
entry points that can getUsers
orGuestCommenters
.Does this close any currently open issues?
closes #1757
Any other comments?
As discussed with @jasonbahl we'll need to provide a filter to revert the name change on this Type for those affected by this breaking change with the release.
I also changed how the
ID
filed got generated on this type, meaning it's prefixed withguest_commenter
now instead ofcomment_author
. This means if anyone has hard coded IDs they will change. Are we okay with this? Does this need to be reverted?I have not written any tests, I can work on them if they're needed.
Where has this been tested?
Operating System: Linux
WordPress Version: 6.0.2