Content Management API Example
GraphQL API for a content management system demonstrating interfaces, interface inheritance, custom directives, and content publishing workflows.
This example demonstrates a content management system GraphQL API with a rich type hierarchy using interfaces. It showcases interface inheritance, custom directives for access control and caching, and content publishing workflows.
API Overview
The CMS API provides:
- Content Types - Articles, pages, and media with shared interfaces
- Publishing Workflow - Draft, review, and publish states
- Access Control - Role-based field access via directives
- Caching - Directive-based cache hints for CDN integration
Interface Hierarchy
The API uses a layered interface structure for type contracts:
{
"interfaces": [
{
"id": "interface-node",
"name": "Node",
"description": "Base interface for all identifiable objects",
"fields": [
{
"id": "field-node-id",
"name": "id",
"typeName": "ID",
"nullable": false,
"description": "Globally unique identifier"
}
]
},
{
"id": "interface-timestamped",
"name": "Timestamped",
"description": "Objects with creation and modification timestamps",
"fields": [
{
"name": "createdAt",
"typeName": "DateTime",
"nullable": false
},
{
"name": "updatedAt",
"typeName": "DateTime",
"nullable": false
}
]
},
{
"id": "interface-content",
"name": "Content",
"description": "Base interface for all content types",
"implementsInterfaces": ["Node", "Timestamped"],
"fields": [
{
"name": "title",
"typeName": "String",
"nullable": false
},
{
"name": "slug",
"typeName": "String",
"nullable": false
},
{
"name": "author",
"typeName": "User",
"nullable": false,
"directives": [
{
"directiveId": "cacheControl",
"arguments": { "maxAge": 300 }
}
]
}
],
"directives": [
{
"directiveId": "cacheControl",
"arguments": { "maxAge": 3600 }
}
]
},
{
"id": "interface-publishable",
"name": "Publishable",
"description": "Content with publishing workflow",
"implementsInterfaces": ["Content"],
"fields": [
{
"name": "status",
"typeName": "PublishStatus",
"nullable": false,
"description": "Current publishing status: DRAFT, IN_REVIEW, PUBLISHED, ARCHIVED"
},
{
"name": "publishedAt",
"typeName": "DateTime",
"nullable": true
},
{
"name": "publishedBy",
"typeName": "User",
"nullable": true,
"directives": [
{
"directiveId": "auth",
"arguments": { "requires": "EDITOR" }
}
]
}
]
}
]
}