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.
\🔌 此重大更改是否会影响插件? | \是 |
---|
\🤖 此重大更改是否由 codemod 自动处理? | \是 |
---|
重大更改描述
¥Breaking change description
在 Strapi v4 中
¥In Strapi v4
publicationState
被使用并接受以下值:
¥publicationState
is used and accepts the following values:
live
仅返回已发布的条目,¥
live
returns only published entries,preview
返回草稿条目和已发布的条目。¥
preview
returns both draft entries & published entries.
在 Strapi 5 中
¥In Strapi 5
status
被使用并接受以下值:
¥status
is used and accepts the following values:
draft
返回文档的草稿版本,¥
draft
returns the draft version of a document,published
返回文档的已发布版本。¥
published
returns the published version of a document.
迁移
¥Migration
本节重新组合了有关引入的重大更改的有用说明和程序。
¥This section regroups useful notes and procedures about the introduced breaking change.
注意
¥Notes
没有后备方案来默认返回已发布的版本,如果未找到已发布的版本,则返回草稿版本。
¥There are no fallbacks to return by default the published version, and return the draft version if no published version is found.
有关如何使用新
status
参数的更多信息,请参阅 REST API、GraphQL API 和 文档服务 API 文档。¥Additional information about how to use the new
status
parameter can be found in the REST API, GraphQL API, and Document Service API documentation.
迁移程序
¥Migration procedure
从使用
publicationState
的前端(REST API、GraphQL API)发起的 API 调用需要手动更新。¥API calls initiated from the front end (REST API, GraphQL API) that used
publicationState
need to be manually updated.如果在 Strapi v4 中的实体服务 API 中自定义后端代码中使用
publicationState
,则 codemod 将自动处理 Strapi 5 的更改(有关更多详细信息,请参阅 实体服务到文档服务迁移参考)。¥If
publicationState
is used in your custom back-end code with the Entity Service API in Strapi v4, a codemod will automatically handle the change for Strapi 5 (see Entity Service to Document Service migration reference for additional details).