Skip to content

Commit c40e27e

Browse files
authored
Add repeatable components/Document Service API breaking change (#2551)
* Add breaking change entry for repeatable components * Add link to DS API update method ref. * Add the breaking change
1 parent bb46c4c commit c40e27e

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

docusaurus/docs/cms/api/document-service.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,10 @@ To update a document and publish the new version right away, you can:
380380

381381
- update its draft version with `update()`, then [publish it](#publish) with `publish()`,
382382
- or directly add `status: 'published'` along with the other parameters passed to `update()` (see [`status` documentation](/cms/api/document-service/status#update)).
383+
:::
383384

385+
:::caution
386+
It's not recommended to update repeatable components with the Document Service API (see the related [breaking change entry](/cms/migration/v4-to-v5/breaking-changes/do-not-update-repeatable-components-with-document-service-api.md) for more details).
384387
:::
385388

386389
### Example

docusaurus/docs/cms/migration/v4-to-v5/breaking-changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,4 @@ You can click on the description of any breaking change in the following tables
100100
| [Some attributes and content-types names are reserved by Strapi](/cms/migration/v4-to-v5/breaking-changes/attributes-and-content-types-names-reserved) | Yes | No |
101101
| [Upload a file at entry creation is no longer possible](/cms/migration/v4-to-v5/breaking-changes/no-upload-at-entry-creation) | Yes | No |
102102
| [Components and dynamic zones should be populated using the detailed population strategy](/cms/migration/v4-to-v5/breaking-changes/no-shared-population-strategy-components-dynamic-zones) | Yes | No |
103+
| [Updating repeatable components with the Document Service API is not recommended](/cms/migration/v4-to-v5/breaking-changes/do-not-update-repeatable-components-with-document-service-api) | Yes | No |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: defaultIndex removed
3+
description: In Strapi 5, it's not recommended to update repeatable components with the Document Service API
4+
sidebar_label: defaultIndex removed
5+
displayed_sidebar: cmsSidebar
6+
tags:
7+
- breaking changes
8+
- middlewares
9+
- upgrade to Strapi 5
10+
---
11+
12+
import Intro from '/docs/snippets/breaking-change-page-intro.md'
13+
import MigrationIntro from '/docs/snippets/breaking-change-page-migration-intro.md'
14+
15+
# Updating repeatable components with the Document Service API is not recommended
16+
17+
In Strapi 5, it's not recommended to update repeatable components with the API, due to some limitations of the new Document Service API.
18+
19+
<Intro />
20+
21+
<BreakingChangeIdCard
22+
plugins
23+
/>
24+
25+
## Breaking change description
26+
27+
<SideBySideContainer>
28+
29+
<SideBySideColumn>
30+
31+
**In Strapi v4**
32+
33+
You could update a repeatable component with its `id`.
34+
35+
</SideBySideColumn>
36+
37+
<SideBySideColumn>
38+
39+
**In Strapi 5**
40+
41+
Strapi 5 uses `documentId` due to the introduction of the [Document Service API](/cms/api/document-service), and you can't update a repeatable component by its `documentId` due to the way the [Draft & Publish](/cms/features/draft-and-publish) feature works with the new API.
42+
43+
</SideBySideColumn>
44+
45+
</SideBySideContainer>
46+
47+
## Migration
48+
49+
<br/>
50+
51+
### Notes
52+
53+
In Strapi 5, draft components and published components have different ids, and you could fetch data like follows:
54+
55+
```js
56+
// Request
57+
GET /articles // -> returns published article
58+
59+
// Response
60+
{
61+
documentId …
62+
component: [
63+
{ id: 2, name: 'component-1' },
64+
{ id: 4, name: 'component-2' },
65+
]
66+
}
67+
```
68+
69+
You can then try to do the following:
70+
71+
```js
72+
PUT /articles/{documentId} // <== Update draft article
73+
{
74+
documentId …
75+
component: [
76+
{ id: 2, name: 'component-1-updated' }, // <== Update component 1
77+
]
78+
}
79+
```
80+
81+
However, this would fail because the component id of the draft article is different from the published one. Therefore, it's not recommended to try to update repeatable components with the Document Service API.

docusaurus/static/llms-full.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,10 @@ Syntax: `update(parameters: Params) => Promise
21172117

21182118
</ApiCall>
21192119

2120+
:::note
2121+
It's not recommended to update repeatable components with the Document Service API (see the related [breaking change entry](/cms/migration/v4-to-v5/breaking-changes/do-not-update-repeatable-components-with-document-service-api.md) for more details).
2122+
:::
2123+
21202124
<!-- ! not working -->
21212125
<!-- #### Update many document locales
21222126

@@ -8880,6 +8884,7 @@ You can click on the description of any breaking change in the following tables
88808884
| [Some attributes and content-types names are reserved by Strapi](/cms/migration/v4-to-v5/breaking-changes/attributes-and-content-types-names-reserved) | Yes | No |
88818885
| [Upload a file at entry creation is no longer possible](/cms/migration/v4-to-v5/breaking-changes/no-upload-at-entry-creation) | Yes | No |
88828886
| [Components and dynamic zones should be populated using the detailed population strategy](/cms/migration/v4-to-v5/breaking-changes/no-shared-population-strategy-components-dynamic-zones) | Yes | No |
8887+
| [Repeatable components can't be updated with the Document Service API](/cms/migration/v4-to-v5/breaking-changes/do-not-update-repeatable-components-with-document-service-api) | Yes | No |
88838888

88848889

88858890

0 commit comments

Comments
 (0)