Frequently Asked Questions

Migration Process & Best Practices

What are the main steps to migrate data to Hygraph?

The migration process to Hygraph involves four main steps: 1) Explore your current data and relations, 2) Create your new schema in Hygraph, 3) Map your content and plan the migration, and 4) Import your existing content using the Asset Upload API and Content API. Each step is designed to ensure a smooth transition and optimal use of Hygraph's features. Learn more.

How should I plan my schema before migrating to Hygraph?

Before migrating, review your existing content types (models) and fields. Decide which structures to keep and which to optimize using Hygraph features like components. Export your current data (e.g., as JSON or CSV) to inspect content types, field names, and relationships. This planning ensures your schema leverages Hygraph's flexibility and efficiency. Read more.

What tools does Hygraph provide for schema creation during migration?

You can create your schema in Hygraph using either the intuitive UI or the Management SDK. The Management SDK allows you to programmatically create models, fields, enums, and relations, making it efficient for large or complex migrations. The UI is ideal for manual setup and smaller projects. SDK Documentation

How do I import assets when migrating to Hygraph?

Assets are imported using the Asset Upload API. For projects created before February 2024, use the Legacy asset system; for newer projects, use the Hygraph Asset Management system. You can upload assets via file or remote URL, and assets are subject to plan-specific size limits. Learn more about asset upload.

What is the recommended order for migrating content and relations?

It is best to migrate assets first, followed by content entries, to ensure that relations (such as references to assets or other entries) can be established correctly. For related content, migrate parent entities before child entities to maintain data integrity.

How do I migrate rich text content to Hygraph?

Hygraph stores rich text as an Abstract Syntax Tree (AST) based on Slate. To migrate rich text, first convert your existing content to the AST format using Hygraph's converter tool, then use a GraphQL create mutation to import the content. Read more.

How can I migrate relational data between models?

To migrate relations, you can use nested GraphQL mutations. For example, create a parent entry (like an Author) and use a nested create or connect mutation for related entries (like Books). Alternatively, create all entries first, then use update or updateMany mutations to establish relations. Learn more.

What are some best practices for migrating to Hygraph?

Best practices include: planning your migration, leveraging Hygraph features (like components), migrating assets before content entries, prioritizing important content, and spacing out mutations to avoid rate limits. Refer to the rate limits documentation for more details.

How do I handle field type mismatches during migration?

If your existing data doesn't map directly to Hygraph field types, you can use String or JSON fields to store the data. However, using the most appropriate field types enables better filtering and querying later. Consider normalizing your schema during migration for optimal results.

Can I automate the migration process to Hygraph?

Yes, you can automate migration using scripts with the Management SDK and Content API. For example, you can use Node.js scripts to read data from CSV or JSON files and perform GraphQL mutations to create entries in Hygraph. See SDK examples.

Where can I find sample migration scripts for Hygraph?

Sample migration scripts are available in the Hygraph documentation, including examples for creating models, fields, and importing data using Node.js and GraphQL. View migration script examples.

How do I migrate assets using a remote URL?

To migrate assets using a remote URL, use the Asset Upload API. For the Hygraph Asset Management system, create the asset via a GraphQL mutation with the uploadUrl parameter. For the legacy system, use the appropriate endpoint for remote uploads. Learn more.

What are the size limits for asset uploads during migration?

Asset upload size limits depend on your Hygraph plan. For example, the Hobby plan allows up to 50MB per asset, while the Growth plan allows up to 200MB per asset. For more details, see the Hygraph pricing page.

How do I publish assets after migration?

After uploading assets, you must publish them for them to be available alongside your content. Use the asset publishing endpoint or the Hygraph UI to publish assets. Learn more about publishing assets.

How do I handle rate limits during migration?

To avoid hitting rate limits, space out your mutations and avoid sending large batches at once. Refer to the rate limits documentation for guidance on optimal mutation pacing.

Can I use the Hygraph UI for migration, or do I need to use code?

You can use the Hygraph UI for manual schema creation and content entry, which is suitable for smaller projects or less technical users. For larger or automated migrations, the Management SDK and Content API are recommended. Learn more about the UI.

What field types does Hygraph support for migrated data?

Hygraph supports over a dozen field types, including strings, booleans, dates, polymorphic relations (Union Types), and remote field-level resolvers for fetching content from other APIs. See all field types.

How do I migrate enumeration or component fields?

Enumeration and component fields must be created at the base schema level before adding them to models. Use the Management SDK for efficient setup. See field creation examples.

What is the purpose of the Management SDK in migration?

The Management SDK allows you to programmatically create and manage your schema, including models, fields, and relations. It is especially useful for tracking changes, automating migrations, and handling complex schemas. Learn more about the SDK.

How do I migrate data from a CSV file to Hygraph?

You can use Node.js scripts with the csvtojson library to convert CSV data to JSON, then use the GraphQL Content API to create entries in Hygraph. Example scripts are provided in the migration documentation. See example.

Features & Capabilities

What features does Hygraph offer for content migration and management?

Hygraph provides a GraphQL-native architecture, content federation, user-friendly tools, and enterprise-grade features such as Smart Edge Cache, localization, and robust asset management. These features streamline migration and ongoing content management. See documentation.

Does Hygraph support API-based migration?

Yes, Hygraph supports migration via multiple APIs, including the Content API, High Performance Content API, Asset Upload API, and Management API. These APIs allow for flexible, programmatic migration and integration with other systems. API Reference.

What integrations are available to support migration and ongoing content management?

Hygraph integrates with popular Digital Asset Management (DAM) systems like Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, and Scaleflex Filerobot. It also supports custom integrations via SDKs and APIs, and offers a marketplace for pre-built apps. See all integrations.

How does Hygraph ensure high performance during and after migration?

Hygraph offers high-performance endpoints designed for low latency and high read-throughput content delivery. The platform actively measures API performance and provides best practices for optimization. Read about performance improvements.

What technical documentation is available to support migration?

Hygraph provides comprehensive technical documentation, including API references, schema guides, webhook details, and AI integration docs. These resources support every stage of migration and ongoing development. See all documentation.

Security & Compliance

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 high standards for data protection, security, and privacy. See secure features.

How does Hygraph protect my data during migration?

Hygraph encrypts data both at rest and in transit, provides granular permissions, audit logs, SSO integrations, and regular backups. Dedicated hosting options and ISO 27001-certified infrastructure further enhance security. Learn more.

Pricing & Plans

What pricing plans does Hygraph offer for migration projects?

Hygraph offers three main plans: Hobby (free forever), Growth (from $199/month), and Enterprise (custom pricing). Each plan has different limits on locales, seats, asset upload size, and support. See pricing details.

What features are included in the free Hobby plan?

The Hobby plan includes 2 locales, 3 seats, 2 standard roles, 10 components, unlimited asset storage, 50MB per asset upload, live preview, and commenting/assignment workflow. Sign up for free.

What additional features does the Growth plan provide?

The Growth plan (from $199/month) offers 3 locales, 10 seats, 4 standard roles, 200MB per asset upload, remote source connection, 14-day version retention, and email support. Get started.

What does the Enterprise plan include for large-scale migrations?

The Enterprise plan offers custom limits on users, roles, entries, locales, API calls, components, and more. It includes advanced features like scheduled publishing, dedicated infrastructure, SSO, multitenancy, instant backup recovery, custom workflows, and dedicated support. Try for 30 days or request a demo.

Use Cases & Success Stories

Who can benefit from migrating to Hygraph?

Hygraph is ideal for developers, product managers, content creators, marketers, solutions architects, enterprises, agencies, eCommerce platforms, media companies, technology firms, and global brands needing scalable, modern content management. See case studies.

What industries are represented in Hygraph's migration case studies?

Industries include SaaS, marketplace, education technology, media and publication, healthcare, consumer goods, automotive, technology, fintech, travel, food and beverage, eCommerce, agencies, online gaming, events, government, consumer electronics, engineering, and construction. Explore all case studies.

Can you share specific migration success stories?

Yes. For example, Komax achieved 3x faster time to market by managing over 20,000 product variations across 40+ markets. Samsung improved customer engagement by 15% after migrating to Hygraph. Komax case study, Samsung case study.

What business impact can I expect from migrating to Hygraph?

Customers report improved operational efficiency, accelerated speed-to-market, cost efficiency, enhanced scalability, and better customer engagement. For example, Voi scaled multilingual content across 12 countries and 10 languages, cutting costs and improving workflows. Voi case study.

How long does it take to implement Hygraph for migration projects?

Implementation time varies by project complexity. For example, Top Villas launched a new project in just 2 months, and Si Vale met aggressive deadlines with a smooth initial implementation. Top Villas case study.

Competition & Differentiation

How does Hygraph compare to traditional CMS platforms for migration?

Hygraph's GraphQL-native architecture, content federation, and user-friendly tools set it apart from traditional CMS platforms that rely on REST APIs and require more developer intervention. Hygraph enables faster schema evolution, easier integration, and more efficient content delivery. See comparisons.

Why choose Hygraph over other headless CMS solutions for migration?

Hygraph is the first GraphQL-native Headless CMS, offering content federation, enterprise-grade features, and proven ROI. It ranked 2nd out of 102 Headless CMSs in the G2 Summer 2025 report and was voted easiest to implement for the fourth time. See G2 report.

What pain points does Hygraph solve during migration?

Hygraph addresses operational inefficiencies (eliminating developer dependency), modernizes legacy tech stacks, ensures content consistency, improves workflows, reduces costs, accelerates speed-to-market, and simplifies integration and schema evolution. See case studies.

How does Hygraph differentiate itself in solving migration challenges?

Hygraph stands out with its GraphQL-native approach, content federation, Smart Edge Cache, and user-friendly tools for non-technical users. Its focus on scalability, integration, and enterprise-grade security makes it ideal for complex migration projects. Learn more.

Help teams manage content creation and approval in a clear and structured way
Hygraph
Docs

#Migrating to Hygraph

#Overview

Migrating from any platform to another isn't a straightforward process, the same goes for a Headless CMS. Hygraph provides the SDK, APIs, and UI to make the process easier to create, and manage your schema and content.

The Hygraph schema and Content API are completely designed by you. This means any content types, and fields you add will immediately be available via the API. There are a few system content types, and system fields you get out of the box, but you can use as much, or as little as you need.

Before you begin creating any schema, or content, take a look at what content, and content types (referred to as "models" at Hygraph) you already have, and what they may look like in Hygraph.

Hygraph supports over a dozen field types, everything from regular strings, booleans, dates, polymorphic relations (Union Types) to remote field level resolvers that let you fetch content from other APIs.

You'll want to begin by deciding on the models, and fields you need.

Some users migrating prefer to take the time now to normalize their schema in a way that could not be done before, but this can often lead to manual intervention when importing content.

If you don't normalize this now, you can always use String, and JSON fields to represent as much of your data without any modification, however you'll lose some benefits with filtering that data at an API later if fields aren't set to their best field types.

This document covers the steps you need to follow to migrate to Hygraph, the tools you will need to use for it, a list of migration best practices, and tips on migrating different fields types, such as assets, rich text, and relations.

Our data migration flow follows four steps:

#1. Explore your current data and relations

This step requires you to look at the structure of the project you're migrating to Hygraph, and then consider Hygraph and its features.

Plan your schemaPlan your schema

When you start thinking about how data should be modeled in your Hygraph project, you'll realize that you may be able to keep some structures as they are due to features in common, and you'll also find that there are structures that you may want to change in order to create an efficient schema that takes advantage of Hygraph's features.

How is your current project structured? Does it have the same structural elements that Hygraph offers to create schemas? Is there anything in your current project's structure that could benefit from using Hygraph features? How do the structures in your project relate to each other?

Look into these questions as you plan the structure of your Hygraph project, including how the structure that you currently have will need to change to use some of Hygraph features - such as components - where it makes sense.

We suggest that you look at your existing data, and export it to a format such as JSON, or CSV. You can use this export to inspect your existing content types, and field names, as well as any relations between data.

For the purposes of this article, we'll use a very basic CSV of authors:

oldId,firstName,lastName
1,Stephen,King
2,Frank,Herbert
3,Brian,Herbert
4,Kevin,Anderson
5,Agatha,Christie
6,Haruki,Murakami
7,Isaac,Asimov

#2. Create your new schema

Create your schemaCreate your schema

Once the schema is planned, you can start the process of creating it in Hygraph. Bear in mind that you will first need to create the schema, and then the content.

You can create the schema using the UI or using the Management SDK to create your models, fields, enums, relations programmatically. Using the Management SDK is faster, more efficient, and it also lets you keep a track record of what's been done.

#Use the Management SDK

To create your schema using the Management SDK you will mostly use create and connect actions. Before we dive into a full example on how we'd use it in a migration, let's look into how we'd use it to create models and fields first.

You will be using createModel to create your models, like this:

client.createModel({
apiId: '<your_api_id>',
apiIdPlural: '<your_api_id_plural>',
description: `<your_model_description>`,
displayName: '<Your model name>',
});

So, if you wanted to create two models, called Author and Book, you'd do something like this:

client.createModel({
apiId: 'Author',
apiIdPlural: 'Authors',
displayName: 'Author',
});
client.createModel({
apiId: 'Book',
apiIdPlural: 'Books',
displayName: 'Book',
});

To create a simple field, you'll be using createSimpleField, like this:

client.createSimpleField({
apiId: `<your_api_id>`,
description: `<your_description>`,
displayName: `<your_display_name>`,
embeddableModels: `<embeddable_models>`,
embedsEnabled: `<boolean>`,
formConfig: `<form_config_json>`,
formExtension: `<form_extension>`,
formRenderer: `<form_renderer>`,
isHidden: `<boolean>`,
isList: `<boolean>`,
isLocalized: `<boolean>`,
isRequired: `<boolean>`,
isTitle: `<boolean>`,
isUnique: `<boolean>`,
migrationValue: `<migration_value>`,
modelApiId: `<model_api_id>`,
parentApiId: `<parent_api_id>`,
position: `<int>`,
tableConfig: `<table_config_json>`,
tableExtension: `<table_extension>`,
tableRenderer: `<table_renderer>`,
type: SimpleFieldType,
validations: `<SimpleFieldValidationsInput>`,
visibility: `<VisibilityTypes>`,
});

So, to create a simple string field in your Author's model to include the author's favorite pastime, you could add something like this:

client.createSimpleField({
parentApiId: 'Author',
type: SimpleFieldType.String,
apiId: 'favoritePastime',
displayName: 'Author Favorite Pastime',
isRequired: true,
visibility: VisibilityTypes.ReadWrite,
});

If your project uses component, enumeration, or remote source fields, you'll need to create those at the base schema level, before you add them to your models. You'll find information on how to create each one in the Management SDK examples for model and field creation document we mentioned above.

Let's now look into a full example:

In the example below, we'll import the @graphcms/management dependency, and create a model, and add some fields.

// migration.js
const { newMigration, FieldType } = require('@graphcms/management');
const migration = newMigration({ endpoint: '...', authToken: '...' });
const author = migration.createModel({
apiId: 'Author',
apiIdPlural: 'Authors',
displayName: 'Author',
});
author.addSimpleField({
apiId: 'firstName',
displayName: 'First Name',
type: FieldType.String,
});
author.addSimpleField({
apiId: 'lastName',
displayName: 'Last Name',
type: FieldType.String,
});
migration.run();

Next, you'll need to run this with node. If you'd like to see the result or any errors of the migration, you can opt to run this migration in the foreground by passing true as the first argument to run().

const result = migration.run(foreground);
if (result.errors) {
console.log(result.errors);
} else {
console.log(result.name);
}

Depending on what filename you gave the migration, you can run node migration.js from the command line.

There are many other options available using the Management SDK, so it's recommended you read through the documentation, and understand everything that is available before using it.

#Use the UI

To create the schema using the UI, you will need to create the models, and then add fields to them.

Our getting started flow has a great section on creating models and adding fields to them.

#3. Map content & plan content migration

Once you create the structure of your project, you can start planning how to import your content. Migrating the content requires that you look at the content that you have and plan how it needs to be migrated taking into consideration the structure you just created for it.

For instance, the order of migration matters when content is related. i.e., you'd have to migrate your assets first so when you migrate the content entries, relations can be successfully established.

Once you have your plan laid out, you can start migrating the content.

#4. Import your existing content

This will be done using the Asset Upload API for assets, then the Content API for content.

API EndpointsAPI Endpoints

#Asset Upload API

Projects older than February 2024 use the Legacy asset system and will show an endpoint that allows uploading assets from your file system or from a remote URL. Newer projects use the Hygraph Asset Management system, which lets you upload assets via URL or file.

Hygraph supports uploading assets via HTTP. You'll need a Permanent Auth Token with Mutations API access enabled to upload by file, or URL.

Assets are treated just like any other content entry, so they are automatically bound to the environment, and authorization settings of your project.

Once this is set up, you can upload assets by file or by remote URL.

To upload by file you can use the following if your project uses the legacy asset system:

And if your project uses the Hygraph asset management system, you need to first create the asset via GraphQL mutation, like this:

And then upload the asset, like this:

URL="https://dev-1-assets-delivery-f78c5b5.s3.eu-central-1.amazonaws.com"
DATE="20240123T173451Z"
KEY="clr7o58jb00w701vwhpc69xda/upload/clr7o587k000j01uhul69p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eu-central-1/s3/aws4_request"
SECURITY_TOKEN="IQoJb3JpZ2luX2VjEKr//////////wEaDGV1LWNlbnRyYWwtMSJHMEUCIEAzHT69GDZoBqzy6L8lLCP1DfsAgqZ3JaFk43vopcFEAiEAkU9cQSSI1BFeyMVcLB5BAkW875A63hdY5g481pF8B+Mq9AMIYxAFGgwzNzkxMDgxNzQ2MDEiDFLs8pvkBGEOZWwReSrRAxjboUthl4mEC7TusLzEqw5ORT9FQI+XaUPYvQf/ROvM8LAVAXTt01fGOBrREQH4CrBKIUm03mAaOwNgCh5haeL8fO6oEBwi1KkfnEjMZkPqRfkI+06a+J4IPXNdtlKzoEU9WxROS312L/+20iRJK6chZha+N3UsI34XGE4/b375tizlYLtDrX7Bb1qHtUMbX7UeTiRZH58KUpF9h+d2Yi6mHn/YFrbUhjNr5F/Zd/aduNg8jJSybVL9m5Yud/vR7zs25wibZI+pNB1WqVsEkb7OD7h5B1eBA9vsLw0JuYE2agbm161tJ6UKp9NGxbeVhS5N497kqWc37zBOvqulTSRGQm8WT+4luc6rweSOIEyLLhZ0OVBIc5CCksV/hP1OgqyGR4gJL9pktaP9tzw1hXrPraQmfDxhiX+Q+Z6+dIaqjV6TipqXjNOc3kEHR06jrvya9QlDlWigvxdZLy0fKsAo/GGANXe3fFK8UrUNlN2HqFxzAaOI4BO2e5TMlS0916YLVT7VqwxG8t459TMAKqzI12x7bSlqXCIGRW5jylk8ZLMfldYKkzx3zucJd6/aSxCW5lMikiFF6+moVAodrMjxhKen6BsQgvLUmdjafiTN2DDD8L+tBjqlATsXgXRgY9EIC2LQq29M1Hdenebcr9aNInaAMQJFZLRyuns7w942xcimlI62jMyEaTs4Y3s7i30aZjsQ6jjL+XJ1RSAnSkigtRYluJHaeibdD32tFCjfacz/eayyXFpH3zG94rQeI5WFAYVWDVrXCvZbQ8oRz5x8sydPAedNGUD8v+2NWX7450SqwWsbmkGezLhgJs6Lr9XRHnkLIctahP5hk84Czw=="
curl --request POST \
--url $URL
--form X-Amz-Date=$DATE
--form key=$KEY
--form X-Amz-Signature=$SIGNATURE
--form X-Amz-Algorithm=$ALGORITHM
--form policy=$POLICY
--form X-Amz-Credential=$CREDENTIAL
--form X-Amz-Security-Token=$SECURITY_TOKEN
--form file=@./test.jpg

Click here to learn more about the Hygraph asset management system

You can also upload files by providing a remote URL, instead of a file. If your project uses the legacy asset system, this is how you would do it:

And if your project uses the Hygraph asset management system, you would create the asset in the same way we showed you for the Upload by file option, and then do this:

mutation test {
createAsset(
data: {
uploadUrl:"https://images.unsplash.com/photo-1682687218147-9806132dc697"
}
) {
id
url
}
}

Click here to learn more about the Hygraph asset management system

#Content API

To find the Content API in your Hygraph project, go to Project Settings > Access > Endpoints > High Performance Content API.

To migrate your content you'll be using mutations, which can even be nested. So, before you can begin creating any content within Hygraph, you'll want to inspect the auto-generated GraphQL mutations for your models that Hygraph automatically created as soon as you created those models.

Since the data living in the old CMS is mostly of a different shape and structure than it currently needs to be, it's quite difficult to create a 1:1 mapping, and import from your existing database to Hygraph. Because of this, you will want to consider tweaking your current dataset to match your new input types.

The following script shows a simple import example using the CSV sample authors file we shared earlier.

We've added comments to the code to explain each step:

// Import necessary libraries
const { GraphQLClient, gql } = require('graphql-request'); // Importing graphql-request library and gql tag
const csvToJson = require('csvtojson'); // Importing csvtojson library
require('dotenv').config(); // Importing environment variables from .env file via the dotenv NPM package
// Initialize GraphQL client with endpoint and authorization headers
const client = new GraphQLClient(process.env.HYGRAPH_ENDPOINT, {
headers: {
authorization: `Bearer ${process.env.HYGRAPH_TOKEN}`,
},
});
// Function to create a GraphQL mutation based on provided data
function createMutation(data) {
// Create the mutation
const mutation = gql`mutation MyMutation {
createAuthor(data: {
firstName: "${data.firstName}",
lastName: "${data.lastName}",
oldId: "${data.oldId}"
}) {
id
}
}`;
return mutation;
}
// Asynchronous function to run the migration process
async function run() {
// Retrieve data from a CSV file and convert it to JSON format
const data = await csvToJson().fromFile('./data.csv');
// Generate an array of GraphQL mutations based on the retrieved data
const mutations = data.map((item) => {
return createMutation(item)
});
// Execute each mutation after a timed delay
mutations.forEach((item, index) => {
setTimeout(() => {
console.log(`Running mutation ${index + 1} of ${mutations.length}`)
// Make a request to the GraphQL endpoint using the generated mutation
client.request(item).then((response) => {
console.log(response)
idsToUpdate.push(response.id)
});// Store the retrieved ID for update
}, (index + 1) * 1000); // Delay each iteration by (index + 1) seconds
});
}
// Running the migration process
run();

#Migrating content

This section contains additional help to migrate certain content types.

#Rich text

When migrating content into Hygraph, you might find that the way we save rich text is not the same your previous service does. Hygraph stores rich text as an Abstract Syntax Tree (AST) behind the scenes, which is based on Slate.

Migrating rich text to Hygraph requires two steps:

  1. Conversion: Before transferring the content, you'll need to convert the way your current system stores rich text to match our AST format. Using our converter tool will ensure compatibility with our structure.
  2. GraphQL Create Mutation: Once the content has been converted into the AST format, you can use a create mutation to migrate it.

Here's an example of a create mutation for rich text:

#Relations

To migrate relations, you can do a create mutation and then a nested mutation.

You would first do a create mutation for a Book with a nested create mutation for an Author, for example. You'd do this for the first book, then for the rest of the books by that author you just do a connect mutation, to connect the rest fo the books to that author that's already been created.

Alternatively, you could create all author entries, then all book entries - both using a create mutation - then use an update mutation to connect them. You can also use an update many mutation to connect them as well.

#Migration best practices

  • Plan your migration before you carry it out.
  • Look into Hygraph's capabilities and recreate your schema optimizing efficiency using our features (i.e. components).
  • Migrate items in the right order for relations to work. i.e. migrate assets before the content entries that contain them.
  • Figure out what is the most important / used content in your project vs. the supporting content, so you can ensure all the really important content can be moved over first.
  • Try not to overload the mutations by doing everything in a single one. For instance, if you have a model that connects to ten other models, it's not generally a good idea to try to create all models and their content at once. Try to space mutations out to keep them running smoothly. Check out our documentation on rate limits to learn more.