Skip to content

Fixes bug with Comment Authors not always returning#2350

Merged
jasonbahl merged 1 commit intowp-graphql:developfrom
jasonbahl:bug/#2348-resolve-comment-authors
Apr 22, 2022
Merged

Fixes bug with Comment Authors not always returning#2350
jasonbahl merged 1 commit intowp-graphql:developfrom
jasonbahl:bug/#2348-resolve-comment-authors

Conversation

@jasonbahl
Copy link
Copy Markdown
Collaborator

What does this implement/fix? Explain your changes.

This fixes a bug where Comment Authors are not always returned if the author is a user, and the user is not considered a public node.

  • update resolver for Comment->author connection to load the CommentAuthor (public) by default, and only use the User node if it's publicly visible
  • update test to query publicly and authenticated

Does this close any currently open issues?

closes #2348

Any relevant logs, error output, GraphiQL screenshots, etc?

Scenario:

Given a user (in my case with databaseId: 4) that has no published content in any public post type, have that user post a comment and approve the comment.

Before:

This comment will return null for the author (because the User Model Layer prevents the User from being returned):

CleanShot 2022-04-22 at 11 54 55

After:

The author is returned as a public CommentAuthor Type:

CleanShot 2022-04-22 at 11 53 50

Any other comments?

Authenticated users would get a User Type returned instead of the CommentAuthor type. This would be useful for things like administrative UIs where more information about the User might be used in the UI:

CleanShot 2022-04-22 at 11 55 43

…uthor (public) by default, and only use the User node if it's publicly visible

- update test to query publicly and authenticated
@jasonbahl jasonbahl added object type: comment Relating to the Comment Type object type: user Relating to the User Type component: query Relating to GraphQL Queries labels Apr 22, 2022
@jasonbahl jasonbahl self-assigned this Apr 22, 2022
@qlty-cloud-legacy
Copy link
Copy Markdown

Code Climate has analyzed commit fc4638d and detected 0 issues on this pull request.

View more on Code Climate.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.005%) to 79.277% when pulling fc4638d on jasonbahl:bug/#2348-resolve-comment-authors into f7ebabb on wp-graphql:develop.

@jasonbahl jasonbahl merged commit d26e321 into wp-graphql:develop Apr 22, 2022
@jasonbahl jasonbahl mentioned this pull request May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: query Relating to GraphQL Queries object type: comment Relating to the Comment Type object type: user Relating to the User Type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question: Can't get user information when not authorized

2 participants