Easily restore your project to a previous version with our new Instant One-click Backup Recovery

Hygraph
Docs

Content stages

You can create your own content stages inside the Hygraph UI, and query content from these stages, as well as publish to.

By default all content is served from the DRAFT stage, unless configured otherwise via a Permanent Auth Token, or by filtering.

You can create custom content stages to publish to from DRAFT. Each project comes with stages DRAFT, and PUBLISHED.

#Create a content stage

  1. Navigate to your project settings.
  2. Open the Content Stages tab.
  3. Press "Add Stage" at the bottom of the list of stages.
  4. Provide the Display name, API ID, a Color for the label and Description in the modal.
  5. Press create.

#Edit a content stage

  1. Navigate to the content stage you want to edit.
  2. Press "edit" in the lower left corner of the stage card.
  3. Press "update" in the lower right corner of the card.

#Delete a content stage

  1. Navigate to the content stage card you want to delete.
  2. Press "delete" and confirm your choice.

#Publishing content

Hygraph automatically generates a publish mutation for each of your content models, including the asset model.

If the models have localized fields, you can greater control the locales you want to publish, and if you want to publish the base entry.

Each time you publish to a content stage, you will create a snapshot of the data as a version.

For example, if we have a product model, the mutation publishProduct will exist. You can use this mutation to publish content to a content stage.

ArgumentInput TpyeDescription
whereProductWhereUniqueInputThe content entry you want to publish, using a filter.
to[Stage!]! = [PUBLISHED]The target published content stage.
locales[Locale!]Optional locales to publish.
publishBaseBoolean = trueWhether to publish the base content entry.
withDefaultLocaleBoolean = true

#Unpublishing content

Similar to publishing content, you can unpublish from a selected content stage.

For example, if we have a product model, the mutation unpublishProduct will exist. You can use this mutation to unpublish content from a content stage.

ArgumentInput TpyeDescription
whereProductWhereUniqueInputThe content entry you want to unpublish, using a filter.
from[Stage!]! = [PUBLISHED]The target content stage to unpublish from.
locales[Locale!]Optional locales to unpublish.
unpublishBaseBoolean = trueWhether to unpublish the base content entry or not.

#Versioning

Versioning allows you to work non-destructively with content. Make changes, and recover previous versions with Hygraph.

Each time you publish to a content stage, history is written.

#Fetching version history

You can fetch all of the history by stage. history is a system field.

For example, let's get all of the history for products.

#Fetching a single version

You can use a the generated [model]Version query to fetch a single version of a content entry.

Since models can be complex, and change over time. The data field is a JSON field that returns a snapshot of the content entry at that time.

Using the id, and revision from the previous query, we can fetch the data of the version, including the relations metadata.