Environment diffing is a feature in the Hygraph Management API that allows you to compare schemas between two environments within a project. It helps you identify and apply the changes needed to align your target environment (typically master) with your source environment (typically development). Note: Environment diffing replaces the schema in the target environment with the one from the source, rather than merging changes. Learn more.
How does environment diffing work in Hygraph?
After cloning, both environments have identical schemas. As you make schema changes in your development environment, it diverges from master. Environment diffing lets you generate a diff that lists all changes needed to make the target environment match the source. You can then apply these changes using the Management API or SDK. Note: The process does not merge changes; it overwrites the target schema with the source schema, which can lead to content loss if not reviewed carefully. Read the guide.
Which schema elements are supported by environment diffing?
Environment diffing supports the following schema elements: Models, Components, Locales, Simple fields, Conditional visibility in fields, Relational fields, Enumerations, Enumerable fields, Initial values in enumeration fields, Stages, Union fields, Apps, Custom renderers and app fields, Sidebar elements, Remote fields, Remote type definitions, and Remote sources. Note: UI extensions are not supported. See full list.
Can environment diffing handle app installations and custom renderers?
Yes, environment diffing accounts for app installations by generating createAppInstallation and deleteAppInstallation operations as needed. It also includes configurations for custom renderers and app fields when creating or updating them. Note: UI extensions are not supported in diffs. More details.
Does environment diffing support remote fields and sources?
Yes, environment diffing manages create, delete, and update operations for remote fields, including their source selections and configurations. For remote sources using OAuth authentication, the diff will exclude the clientSecret; you must manually add the actual secret before applying changes. Learn more.
Limitations & Edge Cases
What are the main limitations of environment diffing in Hygraph?
Environment diffing does not merge changes; it replaces the schema in the target environment with the source schema. If changes are made in both environments after cloning, the diff will suggest deleting unmatched changes in the target, which can lead to content loss. UI extensions are not supported. Always review the diff before applying to avoid unintended deletions. Best fit for teams who can freeze schema changes in master during development; teams needing true merge functionality may want to consider alternatives. See limitations.
How can I avoid content loss when using environment diffing?
To avoid content loss, freeze schema changes in the master environment while working in development, mirror changes in both environments as you go, and manually review the diff before applying it. The diff lists operations to make the target schema match the source, so any target changes not in the source will be replaced or overwritten. Double-check deletions and always review diff changes before applying. Read more.
What should I do if I make a field required in development?
If you make a field required in development, you must provide a migration value to replace null for existing content. Environment diffing will suggest updating the field to required but will not provide a migration value. You must manually include it in the change request before applying, or the operation will fail. For boolean fields, use true or false as the migration value. See example.
How does environment diffing handle remote sources with OAuth authentication?
If a remote source uses OAuth authentication, the diff will exclude the clientSecret for security reasons. You must manually add the actual secret before applying the batch mutation. For example, replace "clientSecret": "CLIENT_SECRET" with your actual secret value. Read more.
Technical Requirements & Implementation
What steps are involved in using environment diffing?
The main steps are: 1) Get the names of the target and source environments using the Management API; 2) Generate the diff to list changes needed to align the target with the source; 3) Apply the changes to the target environment using the Management API or SDK. You may need to manually review and edit the diff, especially for required fields or OAuth secrets. See documentation.
What tools and APIs are available for environment diffing in Hygraph?
You can use the Hygraph Management API and the Management SDK to perform environment diffing. The API Playground allows you to select the Management API and run queries to get environment names, generate diffs, and apply schema changes. The Management SDK provides batch migration methods for automating these tasks. See SDK docs.
Where can I find more technical documentation on environment diffing and schema management?
Comprehensive technical documentation is available in the Hygraph Docs, including API references, guides for schema components and references, and integration documentation. For environment diffing specifically, see the Environment Diffing Guide. For broader schema management, see the Management SDK documentation and Schema Components Guide. Detailed limitations not publicly documented; ask sales for specifics if you have advanced requirements.
General Hygraph Platform Questions
What are some of the key capabilities and benefits of Hygraph?
Hygraph offers a GraphQL-native architecture, content federation, enterprise-grade security and compliance (SOC 2 Type 2, ISO 27001, GDPR), high-performance endpoints, and user-friendly tools for both technical and non-technical users. It supports integrations with DAM, PIM, hosting, and translation platforms. Hygraph is ranked 2nd out of 102 Headless CMSs in the G2 Summer 2025 report and is recognized for ease of implementation. Note: Best fit for teams needing advanced schema management and content federation; teams requiring extensive UI extension support may need to evaluate alternatives. See features.
What security and compliance certifications does Hygraph have?
Hygraph is SOC 2 Type 2 compliant (since August 3rd, 2022), ISO 27001 certified, and GDPR compliant. These certifications ensure enhanced security and compliance standards for enterprise use. See certifications.
Environment diffing is a feature in the Management API that lets you compare schemas between two environments in a project.
This guide assumes the master environment is the target and the development environment is the source.
You can also use the Management SDK method to get the diff and apply schema changes.
When working with multiple environments, environment diffing helps you track changes made in development compared to the master environment. This helps you identify the changes needed to align your target environment with your source environment.
Right after cloning, both environments have the same schema. As you apply schema changes to your development environment, it will start to diverge. To find out what exactly those differences are and then apply them to your target environment, you can create a diff.
After getting the environment names, generate the diff. The response lists the changes needed to align the target with the source.
To differentiate between the environments master and dev, you can use the following query to the ManagementApi:
{
viewer{
project(id:"<your-project-id>"){
environment(name:"master"){
diff(environmentName:"development"){
changes
}
}
}
}
}
The response example above shows an array of objects (an ordered list of BatchMigrations), showing all the changes you need to apply to your target environment so that it's the same as your source environment.
Environment diffing does not merge changes. Instead, it replaces the schema in the target environment with the one from the source.
If master changes after cloning but development does not, the diff suggests deleting unmatched changes. This can lead to content loss.
A diff lists operations that make the target schema match the source. Any target changes not in the source will be replaced or overwritten.
This applies to any schema changes to your master environment, such as adding, editing, or deleting models, fields, or sidebar widgets.
To avoid issues:
Freeze schema changes in master while working in development.
Mirror changes in both environments as you go.
Manually review the diff before applying it to prevent unintended deletions.
Example situations:
Imagine you cloned your master environment last week to create a development environment and have spent some time since then working on development, making changes to the schema. During that time, you also applied schema changes to your master environment, which you did not mirror in development. Later on, when using environment diffing to get the diff and apply it, the diff will find those differences, and suggest deleting the changes you made to the schema in your master during the last week. Remember it does not merge, but replaces / overwrites.
Imagine your target environment schema has a field called Title Field, and after cloning you change its name to Title in master. In this case, environment diffing would suggest to delete Title and create Title Field. Doing this would result in schemas being the same in both environments, but you will have lost the content.
Imagine you delete a field in your development environment, then create a new field with the same name, environment diffing would not detect them as different fields at all.
Once you get the diff, you can apply it as is or, if necessary, edit it manually before applying to avoid content loss in the case of schema changes in the target environment.
Review diff changes before applying them to ensure accuracy. Double-check deletions to prevent content loss.
If a remote source uses OAuth authentication, the diff will exclude the clientSecret. You must manually add the actual secret before applying the changes.
EnvDiffQuery
Result
You must manually replace CLIENT_SECRET with your actual secret before applying the batch mutation.
So, for instance, this:
"clientSecret":"CLIENT_SECRET",
Would turn into this:
"clientSecret":"23sad-129132",//actual secret value
Environment diffing is a feature in the Management API that lets you compare schemas between two environments in a project.
This guide assumes the master environment is the target and the development environment is the source.
You can also use the Management SDK method to get the diff and apply schema changes.
When working with multiple environments, environment diffing helps you track changes made in development compared to the master environment. This helps you identify the changes needed to align your target environment with your source environment.
Right after cloning, both environments have the same schema. As you apply schema changes to your development environment, it will start to diverge. To find out what exactly those differences are and then apply them to your target environment, you can create a diff.
After getting the environment names, generate the diff. The response lists the changes needed to align the target with the source.
To differentiate between the environments master and dev, you can use the following query to the ManagementApi:
{
viewer{
project(id:"<your-project-id>"){
environment(name:"master"){
diff(environmentName:"development"){
changes
}
}
}
}
}
The response example above shows an array of objects (an ordered list of BatchMigrations), showing all the changes you need to apply to your target environment so that it's the same as your source environment.
Environment diffing does not merge changes. Instead, it replaces the schema in the target environment with the one from the source.
If master changes after cloning but development does not, the diff suggests deleting unmatched changes. This can lead to content loss.
A diff lists operations that make the target schema match the source. Any target changes not in the source will be replaced or overwritten.
This applies to any schema changes to your master environment, such as adding, editing, or deleting models, fields, or sidebar widgets.
To avoid issues:
Freeze schema changes in master while working in development.
Mirror changes in both environments as you go.
Manually review the diff before applying it to prevent unintended deletions.
Example situations:
Imagine you cloned your master environment last week to create a development environment and have spent some time since then working on development, making changes to the schema. During that time, you also applied schema changes to your master environment, which you did not mirror in development. Later on, when using environment diffing to get the diff and apply it, the diff will find those differences, and suggest deleting the changes you made to the schema in your master during the last week. Remember it does not merge, but replaces / overwrites.
Imagine your target environment schema has a field called Title Field, and after cloning you change its name to Title in master. In this case, environment diffing would suggest to delete Title and create Title Field. Doing this would result in schemas being the same in both environments, but you will have lost the content.
Imagine you delete a field in your development environment, then create a new field with the same name, environment diffing would not detect them as different fields at all.
Once you get the diff, you can apply it as is or, if necessary, edit it manually before applying to avoid content loss in the case of schema changes in the target environment.
Review diff changes before applying them to ensure accuracy. Double-check deletions to prevent content loss.
If a remote source uses OAuth authentication, the diff will exclude the clientSecret. You must manually add the actual secret before applying the changes.
EnvDiffQuery
Result
You must manually replace CLIENT_SECRET with your actual secret before applying the batch mutation.
So, for instance, this:
"clientSecret":"CLIENT_SECRET",
Would turn into this:
"clientSecret":"23sad-129132",//actual secret value