Models

Your schema is defined by the models you create, and fields you add. Inside the schema editor, you can add fields, create relationships between models, and much more.

All changes to your schema are immediately available via GraphQL.

Create a modelAnchor

All models have the following settings:

PropertyExampleDescription
Display namePostThe name displayed inside Hygraph, and content editors.
API IDPostThe name for fetching a single entry
Plural API IDPostsThe name for fetching multiple entries
DescriptionBlog postsOptional hint for content editors when interacting with fields.

Hygraph will automatically scaffold default values for API ID, and Plural API ID based on the Display name. These values will be available via the API as camel case.


For example, let’s imagine we have the model Post. The following queries, and mutations would be generated by the API automatically, as well as custom input types:

  • post
  • posts
  • postVersion
  • postsConnection
  • createPost
  • updatePost
  • deletePost
  • upsertPost
  • publishPost
  • unpublishPost
  • updateManyPostsConnection
  • deleteManyPostsConnection
  • publishManyPostsConnection
  • unpublishManyPostsConnection

Learn more about queries, and mutations.

Edit a modelAnchor

You can at any time update the settings, and Preview URLs for your content models from within the schema editor.

Delete a modelAnchor

For each of the content models you have created, you can choose to update, or delete from the schema editor.

Deleting a model will also delete all of the content entries.

Adding fieldsAnchor

You can add fields to all custom models, and the system Asset model by selecting the field type from the fields list when viewing a model.

System fieldsAnchor

All models have system fields. You don't need to add an ID, created, or updated timestamp. These are managed by Hygraph automatically.

Learn more about system fields.

Preview URLsAnchor

It's most common to create a preview URL for models that represent a page, and have a field such as a slug.

The fields on your model are available to use within the URL template. For example, a Post model may have the following preview URLs:

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

Embedded typesAnchor

All models can be embedded into the Rich Text Field Type via a configuration setting. On the API side, we create a union relation that references the selected model.