|
| 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 | + |
0 commit comments