Skip to content

Commit 349a58b

Browse files
[Strapi 5] Breaking change for model config path uses uid (#2055)
* Created the model-config-path-uses-uid.md file * Updateded the model-config-path-uses-uid.md file * Added link to the model-config-path-uses-uid.md file in the breaking-changes.md file * Updated Sidebars.js file * Updateded the model-config-path-uses-uid.md file
1 parent 3c4a7ad commit 349a58b

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This page is part of the [Strapi v4 to v5 migration](/dev-docs/migration/v4-to-v
1818

1919
* [Some `env`-only configuration options are handled by the server configuration](/dev-docs/migration/v4-to-v5/breaking-changes/removed-support-for-some-env-options)
2020
* [Configuration filenames should meet strict requirements](/dev-docs/migration/v4-to-v5/breaking-changes/strict-requirements-config-files)
21+
* [Model config path uses uid instead of dot notation](/dev-docs/migration/v4-to-v5/breaking-changes/model-config-path-uses-uid)
2122

2223
## Content API
2324

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: Model config path uses uid instead of dot notation
3+
description: Modules like `api::myapi` and `plugin::upload` should no longer be accessed in the Strapi config using `api.myapi` and `plugin.upload`, but instead using `api::myapi` and `plugin::upload`.
4+
sidebar_label: Model config path uses uid
5+
displayed_sidebar: devDocsMigrationV5Sidebar
6+
tags:
7+
- breaking changes
8+
- configuration
9+
---
10+
11+
import Intro from '/docs/snippets/breaking-change-page-intro.md'
12+
import MigrationIntro from '/docs/snippets/breaking-change-page-migration-intro.md'
13+
import YesPlugins from '/docs/snippets/breaking-change-affecting-plugins.md'
14+
15+
# Model config path uses uid instead of dot notation
16+
17+
In Strapi 5, to retrieve config values you will need to use `config.get('plugin::upload.myconfigval')` or `config.get('api::myapi.myconfigval')`
18+
19+
<Intro />
20+
21+
<YesPlugins />
22+
23+
## Breaking change description
24+
25+
<SideBySideContainer>
26+
27+
<SideBySideColumn>
28+
29+
**In Strapi v4**
30+
31+
Models are added to the configuration using `.` notation as follows:
32+
33+
```jsx
34+
strapi.config.get('plugin.upload.somesetting');
35+
if ( strapi.config.has('plugin.upload.somesetting') ) {
36+
strapi.config.set('plugin.upload.somesetting', false);
37+
}
38+
```
39+
40+
</SideBySideColumn>
41+
42+
<SideBySideColumn>
43+
44+
**In Strapi 5**
45+
46+
Models are added to the configuration using `::` replacing `.` notation as follows:
47+
```jsx
48+
strapi.config.get('plugin::upload.somesetting');
49+
if ( strapi.config.has('plugin::upload.somesetting') ) {
50+
strapi.config.set('plugin::upload.somesetting', false);
51+
}
52+
```
53+
54+
</SideBySideColumn>
55+
56+
</SideBySideContainer>
57+
58+
## Migration
59+
60+
<MigrationIntro />
61+
62+
### Notes
63+
64+
- If an API has a configuration, it should also be accessed using `strapi.config.get(’api::myapi.myconfigval’)`.
65+
66+
- The 'plugin' namespace has temporary support with a deprecation warning. This means that referencing `plugin.upload.somesetting` will emit a warning in the server log and check `plugin::upload.somesetting` instead.
67+
68+
- A codemod has been created to assist in refactoring the strings in user code, replacing `plugin.` or `api.` with `plugin::` and `api::`.
69+
70+
71+
72+
### Manual procedure
73+
74+
A codemod will automatically handle the change in most cases.
75+
76+
In cases were the codemod does not automatically handle the change, users will need to manually replace all their strings to target the new config paths.
77+

docusaurus/sidebars.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,14 @@ const sidebars = {
10621062
items: [
10631063
'dev-docs/migration/v4-to-v5/breaking-changes/removed-support-for-some-env-options',
10641064
'dev-docs/migration/v4-to-v5/breaking-changes/strict-requirements-config-files',
1065+
{
1066+
type: 'doc',
1067+
label: 'Model config path uses uid',
1068+
id: 'dev-docs/migration/v4-to-v5/breaking-changes/model-config-path-uses-uid',
1069+
customProps: {
1070+
new: true,
1071+
},
1072+
}
10651073
]
10661074
},
10671075
{

0 commit comments

Comments
 (0)