Blog
Strapi v5 ヘッドレスCMSの実践ガイド
Strapi v5はDocument Service APIの導入で下書き・公開ワークフローが強化されました。実際のセットアップ手順を解説します。
Strapi v5 の新設計
Strapi v5では内部アーキテクチャが大幅に刷新されました。最大の変更点は「Document Service API」の導入です。
Document Service APIとは
従来のEntity Service APIが廃止され、新しいDocument Service APIが中心になりました。
const articles = await strapi.documents('api::article.article').findMany({
populate: ['cover'],
filters: { publishedAt: { $notNull: true } }
});
下書き・公開の仕組み
v5では各エントリにpublishedAtフィールドがあり、nullの場合は下書き、日時が入っていると公開済みです。
REST APIの変更
- エンドポイントは /api/{content-type}
- documentId が主キーとして使用(UUID形式)
- populate パラメータでリレーション取得
まとめ
Strapi v5は破壊的変更が多いですが、より直感的で型安全なAPIを提供します。