Help articles

Schema type is missing a required property

Every schema type needs both a type and a name property. The type specifies which type your schema type is (e.g. if its a document, an object or a string). The type name is the name of which you will refer to this type later on. E.g. if you want to add a field that is a reference to a value of one of your own schema types, you will typically do something like this:

[
  { // defines the schematype "author"
    name: 'author',
    type: 'document',
    fields: [/*...*/]
  },
  
  //...
  
  { // defines the schema type "book"
    name: 'book',
    type: 'document',
    fields: [
      {name: 'title', type: 'string'},
      {
      name: 'author',
      type: 'reference',
      to: [
        {
          type: 'author' // <-- refers to the schema type "author" by its name
        }
      ]
    }
  }
]

Was this page helpful?

Schema type is missing a required property | Sanity Docs