Skip to content

feat: schema version promotion#8031

Merged
n1ru4l merged 71 commits into
mainfrom
feat-schema-version-promotion
Jun 1, 2026
Merged

feat: schema version promotion#8031
n1ru4l merged 71 commits into
mainfrom
feat-schema-version-promotion

Conversation

@n1ru4l

@n1ru4l n1ru4l commented May 10, 2026

Copy link
Copy Markdown
Contributor

Description

Introduces functionality for promoting a schema version from one target to another target (or the same target), making it the latest version within that target.

This enables workflows such as:

  • Promote schema version from one environment to another environment (staging to production)
  • Quick rollbacks to a specific previous schema version within one environment

A video walkthrough over this feature and implementation details exists here.

What should be reviewed?

  • I want Feedback on the UI
  • I am pretty confident with the database changes and API changes as they are covered with quite a few tests and I also manually confirmed all the behaviours many times 😄 Any comments on that are appreciated though

For either of those feel free to hit me up if you want to walk me through things.

CLI

A new CLI command schema:promote is introduced for promoting schema Version

# Promote specific version to target
hive schema:promote \
  --version 33172112-788d-469b-b06f-d5992b4f1ec7 \
  --to the-guild/graphql-hive/production

# Promote from target to target
hive schema:promote \
  --from the-guild/graphql-hive/staging \
  --to the-guild/graphql-hive/production

Permissions

A new permission schemaVersion:promote is introduced to restrict to which targets a schema version can be promoted.

New History UI

Alongside a new CLI command for performing these promotions this change also comes along a new UI for schema versions with more insights into the individual changes of the subgraphs.

image

A demo with some seeded history has been created on our dev environment.

More UI Screenshots image image image image

Database

The database was altered with new columns for storing the new data that is collected for subgraphs.
Refer to the migration file for a breakdown of all new introduced columns.

The database schema is fully backwards compatible. If any major issues occur on the business logic of the API, we can easily roll it back as all the changes introduced are additional.

GraphQL API

  • New fields have been added to determine the origin of a schema version (publish; delete; promotion)
  • A new mutation for promoting a schema version was introduced

Other

Closes #4021

Comment thread packages/migrations/src/actions/2026.05.07T00-00-00.schema-version-promotion.ts Outdated
@github-actions

github-actions Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-hive/cli 0.60.0-alpha-20260601045530-fa604526b784e75a268b691ca903a3b75e03cab5 npm ↗︎ unpkg ↗︎
hive 11.2.0-alpha-20260601045530-fa604526b784e75a268b691ca903a3b75e03cab5 npm ↗︎ unpkg ↗︎

ALTER TABLE "schema_versions"
ALTER COLUMN IF EXISTS "action_id" DROP NOT NULL
, ADD COLUMN IF NOT EXISTS "origin" jsonb NULL
, ADD COLUMN IF NOT EXISTS "supergraph_changes" jsonb NULL

@n1ru4l n1ru4l May 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We store the public schema changes in a separate table schema_version_changes. However, we do not do anything with that table aside from loading the rows. No custom indices etc.

Thus I made the decision to add the column to store supergraph changes to the schema_versions table directly.

If nobody has objections I will refrain from introducing a new table for this.

Comment thread packages/services/api/src/modules/schema/module.graphql.ts
@github-actions

github-actions Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: fa604526b784e75a268b691ca903a3b75e03cab5

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a schema version promotion feature, allowing users to promote a schema version from one target to another within a project. It includes a new database migration, GraphQL schema updates for the schemaVersionPromote mutation and PromotionSchemaLog type, and significant logic in SchemaPublisher and SchemaVersionStore to handle the promotion process and track version origins. Feedback includes identifying a missing crypto import that will cause runtime errors, a typo in a SQL string, and unsafe array access. Additionally, there are suggestions to update an incorrect migration comment, reconsider the use of a dummy field in the GraphQL schema, and evaluate if STITCHING projects should also support this feature.

Comment thread packages/migrations/src/actions/2026.05.07T00-00-00.schema-version-promotion.ts Outdated
Comment thread packages/services/api/src/modules/schema/module.graphql.ts Outdated
Comment thread packages/services/api/src/modules/schema/providers/schema-publisher.ts Outdated
Comment thread packages/services/api/src/modules/schema/providers/schema-version-helper.ts Outdated
Comment thread packages/services/api/src/modules/schema/providers/schema-version-store.ts Outdated
@n1ru4l n1ru4l force-pushed the feat-schema-version-promotion branch 2 times, most recently from 91ca78a to 05a3f05 Compare May 10, 2026 21:18
Base automatically changed from chore-refactor-schema-version-store to main May 11, 2026 20:59
@n1ru4l n1ru4l force-pushed the feat-schema-version-promotion branch 6 times, most recently from c0f20b4 to 9d6cac5 Compare May 13, 2026 10:49
@n1ru4l n1ru4l changed the title Feat schema version promotion feat: schema version promotion May 13, 2026
Comment on lines +13 to +18
ALTER TABLE "schema_version_to_log"
ADD COLUMN IF NOT EXISTS type hive_subgraph_log_type DEFAULT NULL
, ADD COLUMN IF NOT EXISTS "previous_action_id" UUID DEFAULT NULL REFERENCES "schema_log"("id") ON DELETE CASCADE
, ADD COLUMN IF NOT EXISTS "schema_changes" JSONB DEFAULT NULL
, ADD COLUMN IF NOT EXISTS "subgraph_name" TEXT NULL
;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type stores now more complex information that serves the purpose of tracking how the subgraphs changed between schema versions.

@n1ru4l n1ru4l force-pushed the feat-schema-version-promotion branch 3 times, most recently from 0688fb7 to 7c4350f Compare May 17, 2026 11:44

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated integration tests to use SchemaVersion.meta and SchemaVersion.origin instead of the deprecated field SchemaVersion.log

message = 'Expected non-null value.',
): asserts value is T {
if (value === null) {
if (value == null) {

@n1ru4l n1ru4l May 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this helper was not doing what it should do 😆

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use the fields that are not deprecated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch of tests tor the new schema version promote functionality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New CLI command for promotion a schema version.

@n1ru4l n1ru4l force-pushed the feat-schema-version-promotion branch 3 times, most recently from a3681e8 to fd280ee Compare May 17, 2026 18:20
@n1ru4l n1ru4l force-pushed the feat-schema-version-promotion branch from ab1d72b to 1f340b8 Compare May 29, 2026 14:13
@n1ru4l n1ru4l merged commit 51345a9 into main Jun 1, 2026
23 of 24 checks passed
@n1ru4l n1ru4l deleted the feat-schema-version-promotion branch June 1, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Promote schema version from one target to another target

3 participants