craftcms / gatsby-helper

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

netlify build after user is added fails if user is not included in schema #9

Closed dbvisel closed 3 years ago

dbvisel commented 3 years ago

Description

Hi! I added a new user in my Craft install. My GraphQL schema does not include any users, as the front end doesn't deal with them right now. But this makes the build fail on Netlify:

10:49:58 AM: error "gatsby-source-craft" threw an error while running the sourceNodes lifecycle:
10:49:58 AM: Missing Gatsby node definition for remote type User
10:49:58 AM:   510 |         }
10:49:58 AM:   511 |         // And source, if needed
10:49:58 AM: > 512 |         await sourceNodeChanges(config, { nodeEvents });
10:49:58 AM:       |         ^
10:49:58 AM:   513 |     }
10:49:58 AM:   514 |     await cache.set(`CRAFT_CONFIG_VERSION`, remoteConfigVersion);
10:49:58 AM:   515 |     await cache.set(`CRAFT_LAST_CONTENT_UPDATE`, remoteContentUpdateTime);
10:49:58 AM: 
10:49:58 AM: 
10:49:58 AM:   Error: Missing Gatsby node definition for remote type User
10:49:58 AM:   

If I clear the cache on Netlify and redeploy, it's fine. And I suspect that I could make this go away by adding the users to my Gatsby schema – but my impulse was security-minded, and I thought the less that Gatsby knew the better. Is this the way it should behave?

Thanks!

dbvisel commented 3 years ago

(and I think this also causes Gatsby Cloud failures, though the logs there don't show a lot of info.)

andris-sevcenko commented 3 years ago

but my impulse was security-minded, and I thought the less that Gatsby knew the better.

💯

I'll see if I can patch this and make Gatsby helper a little bit more aware of the schema when queried about updated elements.

andris-sevcenko commented 3 years ago

Okay, just fixed this for the next release.

To get the fix early, change your craftcms/gatsby-helper requirement in composer.json to:

"require": {
  "craftcms/gatsby-helper": "dev-develop#01cae0091109da99668128235898d91b9e46b11c as 1.0.0",
  "...": "..."
}

Then run composer update.

rpiprojectsmgmt commented 2 years ago

I am getting same problem when i changed the files, if we do redeploy and clear cache from netlify it works fine