Can't get menu link to update without clearing build cache

Created on 15 February 2024, 10 months ago

Problem/Motivation

The help text for Only trigger builds for published content reads:

Depending on your content workflow, you may only want builds to be triggered for published content. By checking this box only published content will trigger a build. This means additional entities such as Media or Files will not trigger a rebuild until the content it is attached to is published. The downside is that this will only allow content entities to trigger a rebuild.

My question: Is this supposed to apply to menu links, in addition to Media or Files? Because I can't seem to get the menu to update in Gatsby when it is changed via the node edit form. Selecting Custom menu links under Entity types to send to Gatsby Preview and Build Server doesn't change this behaviour.

To be clear, I can get the menu to update if I run gatsby clean first, so the data is available, just not for an incremental build.

I feel like I must be missing something and would appreciate any hints as to what might be going on here. Thanks!

πŸ’¬ Support request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada othermachines Edmonton, Alberta

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @othermachines
  • πŸ‡ΊπŸ‡ΈUnited States ben.hamelin Adirondack Mountains, NY

    @dudrop We were seeing similar behavior for any non-node bundle with the "Build Published" setting enabled. If you look at the logic in the gatsby_entity_update() hook: https://git.drupalcode.org/project/gatsby/-/blob/2.0.x/gatsby.module?ref...

    it's saying "If build published is set and this is not a node, don't do anything" which doesn't make sense to me logically but does explain why your entity changes aren't showing.

    I would suggest trying to make your changes with the "build published" setting disabled. You should then see your entities in the logs at /admin/config/services/gatsby/fastbuilds/logs

  • πŸ‡¨πŸ‡¦Canada othermachines Edmonton, Alberta

    @ben.hamelin - Thanks for your help! And sorry about the username switcharoo. :D

    What you say makes sense except that media and paragraph entities attached to the node are being updated when the node is saved.

    I'm reluctant to turn that setting off because it will trigger more builds than is reasonably necessary.

    I don't work with Drupal as much as I'd like to these days but I do believe a menu link is a content entity and so should theoretically be treated the same as a paragraph or media entity.

  • πŸ‡ΊπŸ‡ΈUnited States ben.hamelin Adirondack Mountains, NY

    @othermachines agreed, it boils down to what Gatsby needs to know in order to keep the site updated. That will vary from site to site, for example we don't build the menu with Gatsby but we do need paragraph and media data.

    It's also worth reviewing this issue: https://www.drupal.org/project/gatsby/issues/3419600 πŸ’¬ Fastbuilds logic and documentation update Needs review

    I've proposed documentation updates to better align with actual module behavior. The "Build published" is another example of misleading or inaccurate docs. It's not checking for published status, but rather restricting to "NodeInterface" when that is checked. It doesn't make sense, and in general the docs seem more targeted at users who are leveraging Gatsby Cloud. For more custom solutions (we build and host our Gatsby site in a custom cloud environment) the docs and logic don't align.

    I suggest unchecking the "Build Published" setting and then saving your menu item, to see if it shows up in the fatsbuild logs. If it does, it should get picked up by your next build.

  • πŸ‡ΊπŸ‡ΈUnited States ben.hamelin Adirondack Mountains, NY
  • πŸ‡ΊπŸ‡ΈUnited States ben.hamelin Adirondack Mountains, NY

    @codekarate or other maintainers. What's the status of this module?

Production build 0.71.5 2024