Models

Your schema is built by defining content models, and shape your content. You can think of a model similar to a collection in NoSQL or database table.

Models can contain fields for strings, integers, floats, booleans, dates, JSON, enumerations, relationships and much more.

You can define your model fields within the GraphCMS schema editor.

GraphCMS Schema Editor

What name you give your model will automatically generate the applicable queries and mutations.


Working with Models

Create a model:

  1. Navigate to the schema editor in the side-bar.
    If you don't see it, your role does not have access to the schema editor.
  2. In the collapsible side-bar, click the "+ Add" button.
  3. In the modal that appeared, fill in your model information.
    We will suggest plural naming suggestions for you.
  4. Press "Create Model" to enter the field editor window.

Try to think of your content as semantic building blocks and not about their end presentation. For example a model called Gallery might just as easily be queried as images related to a product, post or other top-level content block in your content domain.

Add fields to a model

  1. To add a field, press any of the top-level field-types in the right-hand side-bar.
  2. Fill out the information for the field.
    More information about working with fields here.
  3. You can click-and-drag any of the fields in your model to change their order.

View system fields

Toggle the "show system fields" toggle at the top of the field editor window. You are not able to modify system fields, but you can see which ones are added by default to your model.

Edit or delete a model

  1. Click on the disclosure ellipses next to the name of your model.
  2. Choose between "edit" and "delete"

Asset Models

Assets are a system model that are present on every GraphCMS project. You can add additional fields to the asset here but you cannot modify or remove the pre-defined fields they come with.

This site uses cookies to provide you with a better user experience. For more information, refer to our Privacy Policy