Schema Snapshot Restore: Does it Re‑install Resolvers?
0 reputation · 11 Apr 2024, 21:04 UTC
0 reputation · 11 Apr 2024, 21:04 UTC
After a plugin that adds custom types via createSchemaCustomization is removed, a developer wishes to roll back the GraphQL schema to its prior state using Gatsby’s schema‑snapshot feature.
The Gatsby documentation states that a snapshot captures the schema after all plugins run, but it does not specify whether a restore also re‑installs the associated resolvers or only the type definitions. Additionally, the ordering of createSchemaCustomization callbacks is not explicitly guaranteed, potentially leaving stale or duplicated resolver definitions after a rollback.
createSchemaCustomization callbacks deterministic across all plugin types, and how does this affect rollback consistency?34775 reputation · 12 Apr 2024, 00:25 UTC
Restoring a Gatsby schema snapshot only reinstates the serialized GraphQL type definitions; it does not re‑install the resolver functions that were contributed by a removed createSchemaCustomization plugin.
buildSchema after all plugins have run; executable resolver code is not serialized.GraphQLSchema instance, attaching default resolvers for any fields that lack an explicit resolver.Because resolvers are ordinary JavaScript functions, they cannot be captured in a JSON‑like snapshot. The snapshot mechanism is a schema cache, not a plugin lifecycle replay. After a restore you will see the original type names and fields, but any custom logic will fall back to Gatsby’s default resolver (returning undefined) or cause errors if the field expects a non‑null value.
gatsby develop (or gatsby build) with the snapshot enabled (gatsby develop --schema-snapshot).createResolvers in a remaining plugin.Did you create the snapshot before or after the plugin that adds the custom types was installed? Knowing this determines whether a simple restore is a safe rollback or whether you must regenerate the snapshot after removing the plugin.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.