Skip to content

Commit d61ef80

Browse files
More clarity and precisions on multi relations support (#2796) (#2799)
* Add more info and precisions on multi relations support * Fix typos and mistake with Document Service API Co-authored-by: meganelacheny <megane.lacheny@strapi.io>
1 parent 9ddca76 commit d61ef80

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

docusaurus/docs/cms/api/rest/relations.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ Defining relations between content-types (that are designated as entities in the
1717

1818
Relations between content-types can be managed through the [admin panel](/cms/features/content-manager#relational-fields) or through [REST API](/cms/api/rest) or [Document Service API](/cms/api/document-service) requests.
1919

20-
Relations can be connected, disconnected or set through the Content API by passing parameters in the body of the request:
20+
Relations can be connected, disconnected or set through the Content API by passing parameters in the body of the request. These payloads work for both single-entry relations and multi relations (one-to-many, many-to-one, many-to-many, and many-way). When a relational field allows multiple links, the API expects arrays of relation IDs and returns arrays in responses.
2121

2222
| Parameter name | Description | Type of update |
2323
|-------------------------|-------------|----------------|
2424
| [`connect`](#connect) | Connects new entities.<br /><br />Can be used in combination with `disconnect`.<br /><br />Can be used with [positional arguments](#relations-reordering) to define an order for relations. | Partial |
2525
| [`disconnect`](#disconnect) | Disconnects entities.<br /><br />Can be used in combination with `connect`. | Partial |
2626
| [`set`](#set) | Set entities to a specific set. Using `set` will overwrite all existing connections to other entities.<br /><br />Cannot be used in combination with `connect` or `disconnect`. | Full |
2727

28+
:::note
29+
Multi relations can be managed from the REST API and the [GraphQL API](/cms/api/graphql#fetch-relations): the `connect`, `disconnect`, and `set` operations are available across both APIs. However, the [Document Service API](/cms/api/document-service) does not handle relations.
30+
:::
31+
2832
:::note
2933
When [Internationalization (i18n)](/cms/features/internationalization) is enabled on the content-type, you can also pass a locale to set relations for a specific locale, as in this Document Service API example:
3034

docusaurus/docs/cms/backend-customization/models.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ The `uid` type is used to automatically prefill the field value in the admin pan
248248

249249
#### Relations
250250

251-
Relations link content-types together. Relations are explicitly defined in the [attributes](#model-attributes) of a model with `type: 'relation'` and accept the following additional parameters:
251+
Relations link content-types together. Strapi supports both single-entry relations (one-way and one-to-one) and multi relations where at least one side can point to several entries (one-to-many, many-to-one, many-to-many, and many-way). Multi relations are persisted as arrays in the database layer and are returned as arrays in the Content API responses.
252+
253+
Relations are explicitly defined in the [attributes](#model-attributes) of a model with `type: 'relation'` and accept the following additional parameters:
252254

253255
| Parameter | Description |
254256
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |

docusaurus/docs/cms/features/content-type-builder.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ There are 6 different types of relations:
448448
- <img width="25" src="/img/assets/icons/v5/ctb_relation_manytomany.svg" /> Many-to-many: Content-type A *has and belongs to many* Content-type B
449449
- <img width="25" src="/img/assets/icons/v5/ctb_relation_manyway.svg" /> Many way: Content-type A *has many* Content-type B
450450

451+
:::info Multi relations and single relations
452+
Relations where at least one side can reference several entries are called multi relations. In the Content-type Builder, this includes one-to-many, many-to-one, many-to-many, and many-way relations. These relations appear as multi-select fields in the Content Manager and return arrays from the REST, GraphQL, and Document Service APIs; while single relations (one-way and one-to-one relations) return a single linked entry (see [Managing relations with API requests](/cms/api/rest/relations) for more information).
453+
:::
454+
451455
<Tabs>
452456

453457
<TabItem value="base" label="Basic settings">

0 commit comments

Comments
 (0)