feat: expose commenter edge fields#3208
Merged
jasonbahl merged 6 commits intowp-graphql:developfrom Sep 12, 2024
Merged
Conversation
- refactor WPGraphQL\AdminNotices to be a singleton - instantiate AdminNotices the singleton
…e-admin-notices-a-singleton
- update tests
- expose commentAuthorUrl, commentAuthorEmail and commentAuthor on the Comment model as allowed restricted fields - add name, email, url as edge fields on the CommentToCommenter Connection - test the new edge fields
| }, | ||
| 'comment_author' => function () { | ||
| return ! empty( $this->data->comment_author ) ? absint( $this->data->comment_author ) : null; | ||
| return ! empty( $this->data->comment_author ) ? $this->data->comment_author : null; |
There was a problem hiding this comment.
Avoid too many return statements within this method.
| }, | ||
| 'comment_author_url' => function () { | ||
| return ! empty( $this->data->comment_author_url ) ? absint( $this->data->comment_author_url ) : null; | ||
| return ! empty( $this->data->comment_author_url ) ? $this->data->comment_author_url : null; |
There was a problem hiding this comment.
Avoid too many return statements within this method.
| return ! empty( $this->data->comment_author_url ) ? $this->data->comment_author_url : null; | ||
| }, | ||
| 'commentAuthor' => function () { | ||
| return ! empty( $this->data->comment_author ) ? $this->data->comment_author : null; |
There was a problem hiding this comment.
Avoid too many return statements within this method.
| return ! empty( $this->data->comment_author ) ? $this->data->comment_author : null; | ||
| }, | ||
| 'commentAuthorUrl' => function () { | ||
| return ! empty( $this->data->comment_author_url ) ? $this->data->comment_author_url : null; |
There was a problem hiding this comment.
Avoid too many return statements within this method.
3 tasks
- add ipAddress field
|
Code Climate has analyzed commit 22793d1 and detected 8 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
josephfusco
approved these changes
Sep 12, 2024
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What does this implement/fix? Explain your changes.
This introduces new fields on the "Edge" on the
CommentToCommenterconnection:This allows for the relational data between a Commenter and the Comment to be queried for, in addition to the Commenter node itself.
Why?
Comment Authors can be represented by both their User object data and conditional data related to a specific comment.
By exposing this edge data, the client application can combine data from the
Usernode and theComment.authoredge fields to provide a UI matching similar UIs as the WordPress Dashboard.For example:
In the WordPress Dashboard, when moderating comments, the Author is represented as a mix of a User and comment-specific data.
With these edge fields, we can now query the User that authored the comment as well as the conditional fields specific to the comment:
With this data queried at the edge between the Comment and the Author, we could create a UI similar to what is displayed in the WP Admin, where we see some information (avatar, etc) from the User node, and some information (commenter's name) in place of the User's information:
Does this close any currently open issues?
closes #3197