Skip to content
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

Tags Auto Removes on Incremental Builds With Netlify #39

Open
amanbhattarai4400 opened this issue Aug 14, 2020 · 7 comments
Open

Tags Auto Removes on Incremental Builds With Netlify #39

amanbhattarai4400 opened this issue Aug 14, 2020 · 7 comments

Comments

@amanbhattarai4400
Copy link

So, I added incremental builds in Netlify and tags are getting removed after pushing from Github. Because of that, Related posts feature are also not visible.

Is there a fix? Thank you.

@shadcn
Copy link
Contributor

shadcn commented Aug 14, 2020

Hmm. I'll see if I can reproduce this. So builds work but incremental builds fail?

@amanbhattarai4400
Copy link
Author

No incremental builds are working fine, however, the tags are not appearing in posts and thereby related post feature(which I added) are no longer visible as well.

The tags were working on Gatsby build in my local machine. However sometimes they disappeared and I had to perform gatsby clean.

In short, tags are auto disappearing.

@amanbhattarai4400
Copy link
Author

Any updates with this bug?

@shadcn
Copy link
Contributor

shadcn commented Sep 16, 2020

I still haven't been able to reliably reproduce this issue. Is this still happening?

@maiertech
Copy link

I think this problem is caused by Gatsby's cache. If I run the example-blog locally, I'm running into what I think is the same issue.

The first time I run yarn workspace example-blog run start Gatsby runs fine with no issue. Tags on blog post pages are rendered correctly. When I run the same command again, Gatsby uses its cache and I see the following warning message:

Screen Shot 2020-10-26 at 8 15 27 PM

Template tag-template.js is not run. When I double check with GraphiQL I see this:

Screen Shot 2020-10-26 at 8 20 13 PM

meaning there are no tag nodes. After you run yarn workspace example-blog run clean to erase the cache you are back in business for one run, and subsequent runs with cache trigger the issue.

It looks like Gatsby erases the tag nodes from the cache and they do not get recreated because Gatsby skips onCreateNode and reads all posts from cache.

As to why the tag nodes are deleted from cache, there are two Gatsby issues that give some hints: gatsbyjs/gatsby#11785 and gatsbyjs/gatsby#12981.

I have not fully understood why Gatsby is doing this, but I hope at least you can reproduce the issue of disappearing tags locally.

@shadcn
Copy link
Contributor

shadcn commented Oct 27, 2020

@454de6e Thanks. This is helpful. I'm going to try and reproduce this locally.

@maiertech
Copy link

maiertech commented Oct 27, 2020

As a quick fix you can probably set parent.id on tag nodes to the ID of the post from which they were generated. I know that this parent child relationship is semantically meaningless, because a tag would need to have multiple parents, which I think nodes can't have.

If you look at the docs for onCreateNode it seems it's geared at transforming existing nodes 1:1 and not n:1. I am a little surprised that the tagging use case is so at odds with Gatsby's cache and onCreateNode.

Gatsby's official tagging solution is this: https://www.gatsbyjs.com/docs/adding-tags-and-categories-to-blog-posts/. They avoid creating tag nodes and generate tags pages directly. But I like your idea of generating tag nodes, seems more elegant.

Curious to hear what you think is the best solution.

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

No branches or pull requests

3 participants