Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Strapi 5] Updates to relations in API docs #2100

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

pwizla
Copy link
Collaborator

@pwizla pwizla commented May 2, 2024

This PR:

  • updates the docs for connect, disconnect, and set to use documentIds instead of ids
  • adds a callout to Document Service API with a short example so that users know it works "the same" as with the REST API

Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
documentation ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2024 1:18pm

@pwizla pwizla requested a review from Marc-Roig May 2, 2024 13:15
@pwizla pwizla self-assigned this May 2, 2024
@pwizla pwizla added internal PRs created by the Strapi core team v5 Documentation PR that targets Strapi v5 labels May 2, 2024
@pwizla pwizla added this to the 5.0.0 (stable) milestone May 2, 2024
```js
await strapi.documents('api::restaurant.restaurant').update({
documentId: 'a1b2c3d4e5f6g7h8i9j0klm',
locale: 'fr',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Marc-Roig I'm not sure about this example. I did it by memory, trying to remember the exact syntax from our call. 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! this is a valid syntax :)

Copy link
Contributor

@Marc-Roig Marc-Roig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs looks good !

There are more complex scenarios that we might want to document , maybe they are more advanced and not as useful for the majority, but they might be useful to know.

  • Relation from Category (i18n off) -> Article (i18n on):
    In this situation you can select which locale you are connecting
data: {
    categories: {
      connect: [
        { documentId: 'z0y2x4w6v8u1t3s5r7q9onm', locale: 'en' },
       { documentId: 'z0y2x4w6v8u1t3s5r7q9onm', locale: 'fr' }, // Connect to the same document id but different locale
      ]
   }
}
  • Relation from Category (D&P off) -> Article (D&P on):
    (Probably less relevant than the first one)
data: {
    categories: {
      connect: [
        { documentId: 'z0y2x4w6v8u1t3s5r7q9onm', status: 'draft' },
       { documentId: 'z0y2x4w6v8u1t3s5r7q9onm', status: 'published' }, // Connect to the same document id but different publication states
      ]
   }
}

Note, on any api we expose the "documentId", the user will be able to reference both locale and status .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal PRs created by the Strapi core team v5 Documentation PR that targets Strapi v5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants