Hygraph
Docs

#Models

A model defines the structure of a content type in your project. The models you create and the fields you add make up your schema. Hygraph exposes models and their fields in the GraphQL API as soon as you save it. Content editors then create entries based on those models in the Content editor.

Every Hygraph project includes the following system models:

ModelPurpose
AssetStores images and other files. You can add fields to it, but you cannot delete it.
QueryUsed to configure top-level remote fields. You cannot delete it.
SegmentA named reference used to target a group of users for Variants. You can add fields to it, but you cannot delete it or localize its fields.

You can create custom models for the rest of your content types. Schema changes are available in the GraphQL API as soon as you save them.

#Create a model

Create a model
  1. Navigate to the Schema builder.

  2. In the Schema list, click + Add next to Models. Or, if you're adding a model for the first time, click + Add Model in the center of the screen.

  3. Complete the model settings:

    PropertyExampleDescription
    Display namePostThe name shown in Hygraph for content editors.
    API IDPostThe ID used to fetch a single entry through the API.
    Plural API IDPostsThe ID used to fetch multiple entries through the API.
    DescriptionBlog postsOptional hint for editors working with this model.

    Hygraph auto-fills API ID and Plural API ID from the display name. You can edit them before you save. Avoid reserved terms.

  4. Click Add Model.

Your model appears in the Schema list. It has no custom fields yet. Next, add fields to define what editors can enter.

#Add fields to a model

Fields define the data a model can store. Each field uses one of Hygraph’s supported field types.

  1. Open the model in the Schema builder.
  2. From the Add fields sidebar, select a field type.
  3. Configure the field display name, API ID, and any options or validations.
  4. Click Add.

You can add fields to custom models and to the system Asset model.

Useful field guides:

#System fields

Every model includes system fields such as id, createdAt, updatedAt, and publishedAt. You do not need to add them; Hygraph manages them automatically.

To view system fields on a model, enable Show system fields in the Fields tab.

#Edit a model

  1. Navigate to the Schema builder.
  2. Select the model you want to edit.
  3. Open the model settings (context menu) to update the display name, API IDs, description, or preview URLs.

Changing API IDs after content exists can break existing queries and integrations. Plan renames carefully.

#Delete a model

  1. Navigate to the Schema builder.
  2. Select the model you want to delete.
  3. Open the context menu and choose Delete.

Deleting a model also deletes all of its content entries. System models (Asset, Query, and Segment) cannot be deleted.

#Preview URLs

Preview URLs let editors open a frontend preview of an entry from the Content editor. They are most useful for models that represent a page and include a field such as a slug.

Configure preview URLs in the model settings. You can use fields from the model in the URL template. For example, a Post model might use:

Preview nameURL template
Productionhttps://example.com/blog/{slug}
Staginghttps://staging.example.com/blog/{slug}
Next.js Previewhttps://example.com/api/preview?secret=abc&slug={slug}

For live preview and visual editing setup, see Visual editing.

#Next steps

After your models are in place, you can: