Skip to content

Conversation

@jasonbahl
Copy link
Collaborator

What does this implement/fix? Explain your changes.

This updates the ContentType.isPostsPage resolver to return true for the "Post" ContentType.

Does this close any currently open issues?

closes #2514

Any other comments?

BEFORE

isPostsPage and isFrontPage have to be separately queried for on Page and ContentType types, and isPostsPage returns false for the ContentType that is representing the Posts Page.

CleanShot 2024-02-16 at 13 04 41

AFTER

I can now query isFrontPage and isPostsPage as a field of the UniformResourceIdentifiable Type.

And now we see that isPostsPage appropriately returns true when a ContentType is returned as the posts page.

CleanShot 2024-02-16 at 13 03 01

…returns a `ContentType` that `isPostsPage` field returns true
…ble Interface as any node with a URI should be able to identify whether it is or is not the posts page or front page. Defaults to false, but individual implementing types (ContentType, Page) can override the resolver as applicable.

- update the PostType Model to return true if show_on_front is set to "page" and update Post model to return `false` for `isPostsPage` as a Post Object won't ever resolve as the posts page based on the current NodeResolver strategy (see: https://github.com/wp-graphql/wp-graphql/blob/develop/src/Data/NodeResolver.php#L226)
@jasonbahl jasonbahl self-assigned this Feb 16, 2024

return false;
// the "post" ContentType is always represented as isPostsPage
return 'post' === $this->name;

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.

@jasonbahl jasonbahl changed the title fix: 2514 is posts page on content type fix: 2514 is isPostsPage on content type Feb 16, 2024
@coveralls
Copy link

coveralls commented Feb 19, 2024

Coverage Status

coverage: 84.384% (+0.02%) from 84.366%
when pulling 7ca1dcd on jasonbahl:fix/2514-is-posts-page-on-content-type
into 54d0352 on wp-graphql:develop.

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 7ca1dcd and detected 3 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 3

View more on Code Climate.

@jasonbahl jasonbahl changed the title fix: 2514 is isPostsPage on content type fix: isPostsPage on content type Feb 20, 2024
@jasonbahl jasonbahl merged commit b2712bd into wp-graphql:develop Feb 20, 2024
@jasonbahl jasonbahl mentioned this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On ContentType union in nodeByUri returns incorrect isPostsPage

2 participants