Registry / devops / gatsby-plugin-schema-snapshot

gatsby-plugin-schema-snapshot

JSON →
library4.16.0jsnpmunverified

Creates a snapshot of the Gatsby GraphQL schema by saving minimal type definitions to a file and re-creating the schema from the snapshot during bootstrap. It adds the @dontInfer directive to all top-level types, effectively locking down the schema for production stability. Version 4.16.0 requires Gatsby v5.0.0-next as a peer dependency. This plugin is part of the Gatsby monorepo and is updated alongside Gatsby releases. It is intended for projects that want to prevent schema changes from being introduced unexpectedly, offering control via include/exclude lists and an optional update flag. The plugin is stable but rarely updated independently.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

This is a Gatsby plugin, not a direct import. It is used in gatsby-config.js as a CommonJS require. ESM import is not supported for config.

module.exports = { plugins: ['gatsby-plugin-schema-snapshot'] }

Options must be passed inside the plugin configuration object with a 'resolve' key. The short string form does not accept options.

{ resolve: 'gatsby-plugin-schema-snapshot', options: { path: 'schema.gql' } }

The 'update' option expects a boolean, not a string. It is recommended to use an environment variable like process.env.GATSBY_UPDATE_SCHEMA_SNAPSHOT to control updates.

options: { update: true }

Configures the plugin in gatsby-config.js to lock the GraphQL schema, excluding types from a specific source plugin, and enabling updates via an environment variable.

// gatsby-config.js module.exports = { plugins: [ { resolve: `gatsby-plugin-schema-snapshot`, options: { path: `schema.gql`, exclude: { plugins: [`gatsby-source-npm-package-search`], }, update: process.env.GATSBY_UPDATE_SCHEMA_SNAPSHOT || false, }, }, ], } // To regenerate the snapshot: // GATSBY_UPDATE_SCHEMA_SNAPSHOT=true gatsby develop
Debug
Known footguns
breakingRequires Gatsby v5.0.0-next or later. Using with older Gatsby versions will cause errors.
gotchaIf 'update' is set to false (or omitted), the plugin will NOT overwrite an existing snapshot file. This can cause stale schemas in production.
gotchaBy default, internal and built-in types are excluded. Manually excluding required types may break the GraphQL schema.
deprecatedPlugin is in maintenance mode; not actively developed. New features may not be added.
gotchaThe plugin uses CommonJS and cannot be imported as ESM in gatsby-config.js. Using 'import' will fail.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources