-
Notifications
You must be signed in to change notification settings - Fork 591
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
Update the 'withType' options in 'relationship' fields to allow an array of types #4310
Comments
Yes, this is called a polymorphic relationship. There are internal tickets for this, but so far we haven't had a strong need for it. You can submit a request for it on our product roadmap: https://portal.productboard.com/apostrophecms/1-product-roadmap/tabs/1-under-consideration ("Submit idea" button) Currently the popular workaround is to use an array field. Within the array schema, add a |
I wan to work on this issue @boutell |
Anyone is welcome to take a look, but keep in mind this is a fairly significant feature that also has a design component. |
@boutell I haven't submitted a request on your product roadmap yet. Could it be useful to do so? |
Definitely. |
Is there any update? Thank you |
Not so far. Did you add it to the product roadmap site? Also let me know if you are working with one of our customers. |
Yes, it has been added to the product roadmap. No, I am not working with any of yours customers. The biggest issue is the following: to find another way of acting without using the polymorphic relationship, I created in percorso module a data structure like the following:
This seems to work initially, but when I need to establish a reverse relationship, I encounter difficulties.
but it doesn't work |
Yes, reverse relationships are quite a pain with this setup. They should work, but you'd need one for each possibility and so on. |
I need the new feature too |
Description
Currently, in 'relationship' fields in ApostropheCMS 3, the
withType
options only accepts a single string to specify the relationship type. However, in the previous version, ApostropheCMS 2, this property could accept an array of types, allowing for greater flexibility in managing relationships.Example
Currently:
_customField: {
label: 'custom',
type: 'relationship',
withType: 'type1',
builders: {
// Include only the information you need with a projection
project: {
title: 1,
_url: 1
}
}
}
Proposal:
_customField: {
label: 'custom',
type: 'relationship',
withType: ['type1', 'type2'],
builders: {
// Include only the information you need with a projection
project: {
title: 1,
_url: 1
}
}
}
Motivation
This change would allow developers to define more complex relationships between content, simplifying data structure and making ApostropheCMS 3 even more powerful and adaptable to project-specific needs.
Thank you for your attention!
The text was updated successfully, but these errors were encountered: