craftcms / gatsby-helper

Craft CMS helper plugin for Gatsby.
https://plugins.craftcms.com/gatsby-helper
MIT License
15 stars 6 forks source link

Gatsby complains about missing "sourceID" when saving content without previewing #6

Closed ken-gladeye closed 3 years ago

ken-gladeye commented 3 years ago

Description

I have Live Preview setup with a local Gatsby development as per instruction here

When editing an entry and hit Cmd+S, my local Gatsby displays the following error

"gatsby-source-craft" threw an error while running the sourceNodes lifecycle:

Value of the ID field "sourceId" can't be nullish. Got object with keys:
remoteTypeName, remoteId

Digging a bit deeper, it seems to me that the alertGatsby function in Plugin.php does trigger on save but does not send the required element id. Making the following edit seems to resolve the error to me.

Screen Shot 2021-02-04 at 13 55 45

Happy to do a pull request if you think it's the root cause of the issue.

Steps to reproduce

  1. Install and setup Gatsby Live Preview
  2. Edit an entry then hit Cmd+S

Additional info

andris-sevcenko commented 3 years ago

Is this during live preview or just editing and saving?

ken-gladeye commented 3 years ago

Just when editing and saving the entry not during live preview

andris-sevcenko commented 3 years ago

@ken-gladeye go it, going to look into this!

andris-sevcenko commented 3 years ago

Alright, pushed a fix to the develop branch for this.

Have to implement #7 and should be good for another release. I plan to do that this week!

ken-gladeye commented 3 years ago

awesome thanks @andris-sevcenko!