gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.27k stars 10.32k forks source link

allWpCategory count post is not updating in wpgraphql using gatsby-source-wordpress. #38200

Closed sarniel closed 1 year ago

sarniel commented 1 year ago

Preliminary Checks

Description

My problem is the category count post, the graphql is not updating when I start assigning post in the categories. It's still showing null, even though there is a post in the category. I understand, running clean will fix everything, but shouldn't be automatically updating the graphql as will as in the gatsby cloud?

Here is the simple query.

allWpCategory(filter: {slug: {eq: "boxing"}}) { nodes { name count } }

The count value here should be the same as the wp-admin category.

Reproduction Link

none

Steps to Reproduce

  1. Assign a post to any empty category. (ex: boxing)
  2. Now get the count from the category boxing allWpCategory(filter: {slug: {eq: "boxing"}}) { nodes { name count } }
  3. The value of the count should be 1.

Expected Result

I'm expecting to see value in the category count without clearing the cache.

Actual Result

{ "data": { "allWpCategory": { "nodes": [ { "name": "Boxing", "count": null } ] } }, "extensions": {} }

Environment

//

Config Flags

//

LekoArts commented 1 year ago

Hi!

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Gatsby! 💜

sarniel commented 1 year ago

Hi LekoArts,

Thank you for your immediate response, I'm trying to make a dummy Wordpress, but I'm unsure if this is the right way to do it for reproduction.

Steps:

  1. Please pull this repo git@github.com:sarniel/gatsby-starter-wordpress-blog.git
  2. And go to http://localhost:8000/___graphql and run this query query MyQuery { allWpCategory { nodes { name count } } }
  3. Login to wp-admin user account below and modify one of the posts, moving it to another category.

https://admin.to-educate.com/wp-admin/ username: user
pwd: D4^Y!P%P!GJ03!S#rBNztVV&

  1. After saving, the "Count" value in the graphql allWpCategory should be also updated when the post is triggered, as they are somehow related.

Was this intended behavior? or did I miss something here? I hope it makes sense to you. I'm looking forward to your help.

Thanks!

github-actions[bot] commented 1 year ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

elisavetTriant commented 1 year ago

Hello, any chance on looking into this? Is this something to be expected? Any ideas on workarounds? Thank you in advance.

webdevi121 commented 1 year ago

Hi @elisavetTriant , unfortunately, nothing. I'm still waiting for an answer as well. It's one of the major problems that I'm facing with using gatsby as an SSG.

elisavetTriant commented 1 year ago

@sarniel Thank you for taking the time to open this issue.

@sarniel @webdevi121 I'm not sure we are facing with the same issue exactly, so I'll try to expand a bit on my research thus far.

For my use case, I'm using a query like this on taxonomy lists and tag clouds Components, both on default taxonomies (category, post_tag, etc) and on custom taxonomies, and they don't seem to hydrate with the saving of post related information. Neither the count field data nor the related contentNodes of the related term(s) influenced by the post that they are related to. So I'm scratching my head on where I can catch the related contentNodes count, and to get it to "hydrate" without cleaning the cache and rebuilding every time.

What I can see at the dev server from the listener of the Gatsby plugin, is that it IS actually creating, updating or deleting post nodes plus updating author information.

One other thing to consider, is that WordPress itself does NOT update automatically the count with such operations but rather deep inside of its lifecycle. Take a look at this private function for instance: _update_post_term_count/

So really at this point I would appreciate any feedback and/or guidance on this issue. Thank you in advance.

github-actions[bot] commented 1 year ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

github-actions[bot] commented 1 year ago

Hey again!

It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜