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

Hygraph
Docs

Add fields

We will now add some fields to our Product model for a product name, price and image.

To add a field, select one of the field types from the right side of the schema editor.

List of available fieldsList of available fields

#Create a name field

Select Single line text from the available types and set the Display name to Name.

Configure field nameConfigure field name

Then make sure to enable Make field required in the VALIDATIONS tab.

Set field as requiredSet field as required

Once you're happy configuring this field, click the Add button.

Add fieldAdd field

#Create a price field

Let's now add another field, but using the Integer type. Select Number from the available types, and set the Display name to Price.

Configure field nameConfigure field name

Then make sure to enable Make field required in the VALIDATIONS tab.

Set field as requiredSet field as required

Once you're happy configuring this field, click the Add button.

Add fieldAdd field

#Create an image field

We'll now add our final field, and for this we'll use the Asset model as a relation for multiple product photos.

The Asset model is a special type of field that allows us to store images and other files.

Select Asset Picker from the available types and set the Display name to Image. Make sure to also select Allow multiple values:

Configure asset fieldConfigure asset field

Once you're happy configuring this field, click the Add button.

Add fieldAdd field

Now your Product model should now look a little something like this:

Product model fieldsProduct model fields

#Explore system fields

Hygraph by default handles system fields for things such as the id, createdAt, publishedAt, and more .

You can see all of the system fields for your selected model by clicking on Show system fields:

Show system fieldsShow system fields