publicationState 被移除并由 status 替代
🌐 publicationState is removed and replaced by status
在 Strapi 5 中,草稿与发布功能 已经被重新设计,内容 API,包括 REST、GraphQL 和文档服务 API,接受一个新的 status 参数。
🌐 In Strapi 5, the Draft & Publish feature has been reworked, and the Content API, including REST, GraphQL, and Document Service APIs accept a new status parameter.
此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。
🌐 This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.
重大变更描述
🌐 Breaking change description
在 Strapi v4 中
publicationState 已使用,并接受以下值:
live仅返回已发布的条目,preview返回草稿条目和已发布条目。
在 Strapi 5 中
status 已使用,并接受以下值:
draft返回文档的草稿版本,published返回文档的已发布版本。
迁移
🌐 Migration
本节重新组合了有关引入的重大更改的有用说明和程序。
🌐 This section regroups useful notes and procedures about the introduced breaking change.
注意
🌐 Notes
- 没有后备方案来默认返回已发布的版本,如果未找到已发布的版本,则返回草稿版本。
- 关于如何使用新的
status参数的更多信息,可以在 REST API、GraphQL API 和 文档服务 API 文档中找到。
迁移程序
🌐 Migration procedure
- 从前端发起的使用
publicationState的 API 调用(REST API、GraphQL API)需要手动更新。 - 如果在你的自定义后端代码中使用
publicationState与 Strapi v4 的实体服务 API,codemod 将自动处理 Strapi 5 的更改(有关更多详细信息,请参见 从实体服务迁移到文档服务参考)。