Skip to main content
The ContentType type defines the structure and validation rules for content items.

Type Definition

type ContentType {
  id: ID!
  name: String!
  description: String!
  packageVersion: String!
  schema: String!
  createdAt: DateTime!
  updatedAt: DateTime!
}

Fields

FieldTypeDescription
idID!Unique identifier
nameString!Content type name
descriptionString!Content type description
packageVersionString!Package version for component resolution
schemaString!JSON Schema defining content structure
createdAtDateTime!Creation timestamp
updatedAtDateTime!Last update timestamp

Field Details

packageVersion

Content types are bound to a specific package version. This ensures that the components referenced in the content type’s layout are available when rendering content.

schema

The schema field contains a JSON Schema that defines the content structure:
{
  "type": "object",
  "properties": {
    "title": {
      "type": "string",
      "description": "Article title",
      "minLength": 1,
      "maxLength": 200
    },
    "body": {
      "type": "string",
      "description": "Article body content"
    },
    "author": {
      "type": "string",
      "description": "Author name"
    },
    "publishDate": {
      "type": "string",
      "format": "date-time",
      "description": "Publication date"
    },
    "tags": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Article tags"
    },
    "featuredImage": {
      "type": "string",
      "format": "uri",
      "description": "Featured image URL"
    }
  },
  "required": ["title", "body"]
}
Content items of this type must conform to this schema.

Example Queries

List Content Types

query GetContentTypes($search: String) {
  contentTypes(search: $search) {
    data {
      id
      name
      description
      packageVersion
    }
    pagination {
      total
    }
  }
}

Get Content Type with Schema

query GetContentType($id: ID!) {
  contentType(id: $id) {
    id
    name
    description
    packageVersion
    schema
    createdAt
    updatedAt
  }
}
Response:
{
  "data": {
    "contentType": {
      "id": "ct123",
      "name": "Article",
      "description": "Blog articles and news posts",
      "packageVersion": "2.0.0",
      "schema": "{\"type\":\"object\",\"properties\":{\"title\":{\"type\":\"string\"},\"body\":{\"type\":\"string\"}},\"required\":[\"title\",\"body\"]}",
      "createdAt": "2024-01-10T10:00:00Z",
      "updatedAt": "2024-01-15T14:30:00Z"
    }
  }
}

Schema Validation

When creating or updating content, the content data is validated against the content type’s schema:
  • Required fields must be present
  • Type validation ensures fields match expected types
  • Format validation checks strings against formats (date-time, uri, email)
  • Constraints like minLength, maxLength, minimum, maximum are enforced
  • Content - Content items that use this type
  • Package - Package version bound to content type