Get the latest insights, best practices, and tips from power users

Hygraph
Docs

Field configuration

#Settings

Each field must have the following settings configured to be added to a model:

PropertyDescription
Display nameThis is what is shown to content editors throughout the application
API IDThis is what is exposed within the API as a field within your model.
DescriptionDisplays a hint for content editors and API users.

#Options

Not all options are available for all field types.

#Use as a title field

You can set multiple fields as titles to appear within the relational picker instead of IDs.

#Allow multiple values

You should select this if you wish to accept multiple values, and return an array to the API for this field.

#Localize field

Enabling this field allows translations per locale configured on your project.

#Embed options

This setting is only available for Rich text fields.

Rich text embeds need to enabled per field. You can do this from inside the Field Settings when adding a new, or editing a Rich Text field. Click Enable embedding and select the models that should be embeddable in your Rich text field.

Rich Text OptionsRich Text Options

#Validations

Not all validation options are available for all field types.

#Make field required

Marking this prevents content from being saved if it is left empty. The API will mark this field as non nullable.

#Set field as unique

Enabling this ensures content cannot be saved if the same value exists within another entry for this field. Uniqueness is checked per Content stage.

#Limit character count

This validation allows you to specify the minimum/maximum character counts. You can set At least, Between, and No more than, with a custom error message.

#Match a specific pattern

This validation allows you to only accept a specific regular expression.

Common patterns

You can use an existing common pattern from the web app, or provide your own.

URL

(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)

Phone

^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$

Email

^([a-z0-9_\.\+-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$

Slug

^[a-z0-9]+(?:-[a-z0-9]+)*$

Unicode characters

Hygraph field validations support unicode (non-latin) characters. You can add Unicode character classes - which typically correspond to specific alphabets - to a custom Regular Expression field validation.

You can read about the syntax here.

#Restrict a specific pattern

This validation option allows you to not accept specific regular expression.

#Advanced

Not all advanced settings are available for all field types.

#Set initial value

You can define an initial value for content editors. This doesn't have any effect on the API when performing mutations.

#Field visibility

OptionDescription
Read / WriteThe field will be accessible for read/write operations. Default.
Read OnlyThe field will be shown, but cannot be edited in the UI. You can update via the API if required.
HiddenThe field will not be shown in the UI, but can be referenced by other fields such as Slugs, or UI Extensions.
API OnlyField is not shown in the UI, but can be used via the API using mutations.