gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.29k stars 10.31k forks source link

Gatsby update run does change the types #19917

Closed Simply007 closed 4 years ago

Simply007 commented 4 years ago

Summary

I am writing the first class source plugin for Kentico Kontent and I am facing the issue, but only on Gatsby Cloud.

I have a problem with different behavior between local refresh and the refresh on Gatsby Cloud.

Basically handling of the refresh is working normally on the local dev server with the refresh point enabled and cause schema regeneration (modification) on the Gatsby Cloud.

I have described how to reproduce the problem with the reproduction steps to this branch of the gatsby starter so that you could test this locally.

Relevant information

Gatsby source plugin is in v 4.1.0-beta6 - https://github.com/Kentico/gatsby-source-kontent/tree/preview-functionality

Source plugin is not re-defining the schema - schema is defined only for the initial run, update run does not change the Note types, so I haven't seen a reason to do that for the update. But if this was an issue it would have been broken on local development when hitting the refresh. Are there any differences between local and Gatsby cloud in code execution that could cause schema modification?

Environment (if relevant)

Local environment that works: System: OS: Windows 10 CPU: (8) x64 Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz Binaries: npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD Languages: Python: 2.7.17 Browsers: Edge: 44.18362.449.0 npmPackages: gatsby: ^2.18.4 => 2.18.4

Simply007 commented 4 years ago

I have been calling createTypes in the sourceNodes method, not in the createSchemaCustomization method.

Moving the schema definition to createSchemaCustomization solved the issue!