craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

UpdateNodes | Cannot read properties of null (reading 'map') #114

Closed delasign closed 1 year ago

delasign commented 1 year ago

Description

When updating Gatsby, if the plugin detects changes that are outside of the schema that the token has access to, the updatedNodes will return null.

info Craft config version has not changed since last sourcing. Checking for content
changes since "2023-08-13 19:46:53".
UPDATED NODES : null
DELETED NODES : [object Object]

 ERROR #11321  API.NODE.EXECUTION

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

Cannot read properties of null (reading 'map')

  576 |         // Create the sourcing node events
  577 |         const nodeEvents = [
> 578 |             ...updatedNodes.map((entry) => {
      |                             ^
  579 |                 return {
  580 |                     eventName: "UPDATE",
  581 |                     remoteTypeName: entry.nodeType,

File: ../gatsby-source-craft/gatsby-node.js:578:29

  TypeError: Cannot read properties of null (reading 'map')

This occurs on PostMan: image

And on the CraftCMS GraphiQL: image

Steps to reproduce

  1. Create a project that works with the GraphQL & Gatsby (with the Gatsby-source-plugin)
  2. When creating a token, do not give it access to everything.
  3. Run gatsby develop successfully
  4. Make a change outside of the schema that the token has access to.
  5. Refresh Gatsby / run gatsby develop again

Additional info

Craft version: Craft Pro v4.4.17 PHP version: 8.0.28 Database driver & version: MySQL 8.0.31 Plugins & versions: Amazon S3 | 2.0.3 Field Manager | 3.0.6 Mail Service (Custom, Non Released Plugin) | 1.0.0 Redactor | 3.0.4 Remote Sync | 4.1.1 Super Table | 3.0.9 Gatsby Helper | 2.0.1

i-just commented 1 year ago

Closing in favour of: https://github.com/craftcms/gatsby-helper/issues/31