Open MPiland opened 1 month ago
Hi @MPiland this is expected behavior in Gen 2. I've marked it as a feature request for the team to discuss and consider.
Hi @chrisbonifacio thanks for the feedback! Can we add to that feature request to also allow a many-to-many-to-many or ternary type of join table? Or at least have a solution/example of how that should be done?
Using the models above it would be something like:
Originally I had a join table for categories to types and then used the id from that object to map to a categoryType to method but because of the way the join data comes out, it didn't work.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Not applicable
Amplify Version
v6
Amplify Categories
api
Backend
Amplify Gen 2 (Preview)
Environment information
Describe the bug
When using a join table to create a many-to-many relationship, when I get the data from one side of the table or the other, the objects returned in the array are the join table objects, not the objects on the other side of the table. Is this normal or expected? It seems to be an odd behavior especially if I'm wanting to nest the data properly. Here's my example
I'm actually trying to create a many-to-many-to-many type of nested situation, but that's a different question. First, I need to solve the first join table issue. Now, when I query the even just the ModifierCategory model like such
I get back an array of objects that are the join table objects, not the types from the ModifierTypes data table. However, if I query like this
I see the type objects, but they're nested under the objects under the types array like this
Again, if this was the expected behavior, I'll close this, but it makes nested data that are separated models a bit difficult with many-to-many relationships.
Expected behavior
I expected to see the actual types nested under the types array of the query rather than the objects of the join table.
Reproduction steps
Create two models with a many-to-many relationship and use a join table to connect the relationships. Then query one side or the other as nested.
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response